//package com.plian.system.service.fr.indicators.impl;
//
//import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.ExcelWriter;
//import com.alibaba.excel.write.metadata.WriteSheet;
//import com.alibaba.excel.write.metadata.fill.FillConfig;
//import com.alibaba.excel.write.metadata.fill.FillWrapper;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.plian.Tools.*;
//import com.plian.Tools.operation.OperationExpressionUtil;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.config.RedisUtils;
//import com.plian.system.config.exception.MyRuntimeException;
//import com.plian.system.constant.pf.AppraisalIndexConstant;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.dto.fr.indicators.IndicatorsValueDTO;
//import com.plian.system.entity.fr.indicators.BaseMainIndicators;
//import com.plian.system.entity.fr.indicators.BusinessIndicatorsInfo;
//import com.plian.system.entity.fr.indicators.ComplexIndicatorsValue;
//import com.plian.system.entity.fr.indicators.MainIndicatorsInfo;
//import com.plian.system.entity.pf.AppraisalIndex;
//import com.plian.system.entity.sys.Org;
//import com.plian.system.mapper.fr.indicators.BaseMainIndicatorsMapper;
//import com.plian.system.mapper.fr.indicators.IndicatorsValueMapper;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.mybatis.base.BaseFlowService;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.node.ForestNodeMerger;
//import com.plian.system.properties.GzwProperties;
//import com.plian.system.service.fr.indicators.IBaseMainIndicatorsService;
//import com.plian.system.service.fr.indicators.IBusinessIndicatorsInfoService;
//import com.plian.system.service.fr.indicators.IComplexIndicatorsValueService;
//import com.plian.system.service.fr.indicators.IMainIndicatorsInfoService;
//import com.plian.system.service.pf.IAppraisalIndexService;
//import com.plian.system.service.sys.file.FileService;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.service.wf.FormWorkflowService;
//import com.plian.system.vo.fr.indicators.BaseMainIndicatorsVO;
//import com.plian.system.vo.fr.indicatorsValue.IndicatorsValueVO;
//import com.plian.system.vo.report.HeaderVO;
//import com.plian.system.vo.report.ReportReturnVO;
//import com.plian.system.vo.report.ReportVO;
//import com.plian.system.vo.sys.OrgVO;
//import com.plian.system.wrapper.fr.indicators.BaseMainIndicatorsWrapper;
//import com.plian.system.wrapper.fr.indicators.BusinessIndicatorsInfoWrapper;
//import com.plian.system.wrapper.fr.indicators.MainIndicatorsInfoWrapper;
//import com.plian.system.wrapper.sys.OrgWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.exception.ExceptionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.core.env.Environment;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.io.InputStream;
//import java.math.BigDecimal;
//import java.util.*;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//import static com.plian.system.constant.fr.IndicatorsCodeConstant.GMJZCSYL;
//import static com.plian.system.constant.fr.IndicatorsCodeConstant.JZCSYL;
//import static com.plian.system.constant.sys.FormStatusConstant.FINISH;
//import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;
//import static com.plian.system.constant.sys.FormTypeConstant.FR_MAIN_INDICATORS;
//
//@Slf4j
//@Service
//@AllArgsConstructor
//public class BaseMainIndicatorsServiceImpl extends BaseServiceImpl<BaseMainIndicatorsMapper, BaseMainIndicators> implements IBaseMainIndicatorsService, BaseFlowService {
//
//    private IOrgService orgService;
//    private IAppraisalIndexService appraisalIndexService;
//    private IMainIndicatorsInfoService mainIndicatorsInfoService;
//    private IBusinessIndicatorsInfoService businessIndicatorsInfoService;
//    private FormWorkflowService formWorkflowService;
//    private BaseMainIndicatorsWrapper baseMainIndicatorsWrapper;
//    private BusinessIndicatorsInfoWrapper businessIndicatorsInfoWrapper;
//    private MainIndicatorsInfoWrapper mainIndicatorsInfoWrapper;
//    private IndicatorsValueMapper indicatorsValueMapper;
//    private GzwProperties gzwProperties;
//    private Environment environment;
//    private RedisUtils redisUtils;
//    private FileService fileService;
//
//    private IComplexIndicatorsValueService complexIndicatorsValueService;
//
//    private OrgWrapper orgWrapper;
//
//    private final static String IS_UNIT = "1";
//    private final static Integer UNIT_BASE_TYPE = 1;
//    private final static Integer SECOND_ORG_BASE_TYPE = 2;
//    private final static Integer VIRTUAL_ORG_BASE_TYPE = 3;
//    private final static String SUMMARY_NAME = "合并数";
//    private final static int GROUP = 1;
//    private final static int SINGLE = 0;
//    private final static String ORG_NAME_KEY = "orgName";
//    private final static String ORG_ID_KEY = "orgId";
//    private final static String LAST_COMPLETE_VALUE_KEY = "lcvKey";
//    private final static String BEFORE_LAST_COMPLETE_VALUE_KEY = "blcvKey";
//    private final static String BUDGET_VALUE_KEY = "bvKey";
//    private final static String TREND_CHANGE_KEY = "tcKey";
//    private final static String CHANGE_REASON_KEY = "crKey";
//    private final static String MAX_MONTH ="12";
//
//    private final static String LAST_GROWTH_RATE_KEY = "lgrKey";
//
//    private final static String BUDGET_GROWTH_RATE_KEY = "bgrKey";
//
//    private final static String CHILDREN_KEY = "children";
//
//    private final static Integer  VIRTUAL_ORG_TYPE = 3;
//
//    private final static String YUANSHUI_NAME = "宁波原水有限公司";
//
//    private final static String YEAR_KEY = "year";
//
//    private final static String JZCSYL_NAME = "净资产收益率";
//
//    private final static String GMJZCSYL_NAME = "归母净资产收益率（%）";
//
//    private final static String JLR_NAME = "净利润";
//
//    private final static String QMJZC_NAME = "期末净资产";
//
//
//
//    @Override
//    public ListResult<BaseMainIndicatorsVO> treeList(Query query) {
//        List<Org> orgList = orgService.findMainIndicatorsOrg();
//        if (CollectionUtil.isEmpty(orgList)){
//            throw new MyRuntimeException(new ObjResult("获取单位信息失败！"));
//        }
//        List<OrgVO> orgVOList = ForestNodeMerger.merge(orgWrapper.entityToVO(orgList));
//
//        List<String> orgIds = orgList.stream().map(Org::getId).collect(Collectors.toList());
//        ListResult<BaseMainIndicatorsVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        IPage<String> fillingYearPage = getBaseMapper().getFillingYearPage(Condition.getPage(query), orgIds, query.getKeyword());
//        if (CollectionUtil.isEmpty(fillingYearPage.getRecords())){
//            return listResult;
//        }
//        List<BaseMainIndicatorsVO> baseMainIndicatorsVOS = baseMainIndicatorsWrapper.entityToVO(list(Wrappers.<BaseMainIndicators>lambdaQuery()
//                .in(BaseMainIndicators::getFillingYear, fillingYearPage.getRecords())));
//        Map<String, List<BaseMainIndicatorsVO>> fillingYearMap = baseMainIndicatorsVOS.stream().collect(Collectors.groupingBy(BaseMainIndicatorsVO::getFillingYear));
//        List<BaseMainIndicatorsVO> results = new ArrayList<>();
//        fillingYearMap.forEach((k, dataList) -> {
//            Map<String, BaseMainIndicatorsVO> orgIdMap = dataList.stream().collect(Collectors.toMap(BaseMainIndicatorsVO::getFillingUnitId, vo -> vo));
//            results.addAll(orgVOToIndicatorsVO(k, orgVOList, orgIdMap));
//        });
//        listResult.setTotal(Long.valueOf(fillingYearPage.getTotal()).intValue());
//        listResult.setList(results);
//        return listResult;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public BaseMainIndicatorsVO initialization(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        if (StringUtil.isBlank(baseMainIndicatorsVO.getFillingYear())){
//            throw new MyRuntimeException(new ObjResult("上报年度为空！"));
//        }
//        String tokenOrgId = TokenUtil.getTokenOrgId();
//        BaseMainIndicators baseMainIndicators = getOne(Wrappers.<BaseMainIndicators>lambdaQuery()
//                    .eq(BaseMainIndicators::getFillingYear, baseMainIndicatorsVO.getFillingYear())
//                    .eq(BaseMainIndicators::getFillingUnitId, tokenOrgId));
//        if (baseMainIndicators != null){
//            throw new MyRuntimeException(new ObjResult("该年度已填报！"));
//        }
//        String lastYear = String.valueOf(Integer.valueOf(baseMainIndicatorsVO.getFillingYear()) - 1);
//        List<AppraisalIndex> appraisalIndexList = appraisalIndexService
//                .listByTableCodeAndYear(AppraisalIndexConstant.MAIN_INDICATORS_CODE, lastYear);
//        if (CollectionUtil.isEmpty(appraisalIndexList)){
//            throw new MyRuntimeException(new ObjResult("指标配置信息获取失败"));
//        }
//
//        String countDate = baseMainIndicatorsVO.getFillingYear() + "-12";
//        Org tokenOrg = orgService.getById(tokenOrgId);
//        boolean unitFlag = IS_UNIT.equals(tokenOrg.getIsUnit()) && (!orgService.getDTFlag(countDate) || !orgService.isDT(tokenOrgId));
//        BaseMainIndicators initBase = new BaseMainIndicators();
//        initBase.setFillingYear(baseMainIndicatorsVO.getFillingYear());
//        initBase.setFillingUnitId(tokenOrgId);
//        initBase.setFormType(String.valueOf(FR_MAIN_INDICATORS));
//        initBase.setIsDeepeningBudget(0);
//        initBase.setBaseType(unitFlag ? UNIT_BASE_TYPE : SECOND_ORG_BASE_TYPE);
//        if (VIRTUAL_ORG_TYPE.equals(tokenOrg.getType())){
//            initBase.setBaseType(VIRTUAL_ORG_BASE_TYPE);
//        }
//        saveOrUpdate(initBase);
//        BaseMainIndicatorsVO initBaseVO = baseMainIndicatorsWrapper.entityToVO(initBase);
//        initBaseVO.setFillingUnitName(tokenOrg.getName());
//        formWorkflowService.startProcessAndSimulate(String.valueOf(initBase.getId()), initBase.getFormType(), new HashMap<>());
//
//        List<MainIndicatorsInfo> mainIndicatorsInfoList = new ArrayList<>();
//        if (unitFlag){
//            //集团
//            List<BusinessIndicatorsInfo> businessIndicatorsInfoList = new ArrayList<>();
//            unitInfoInit(mainIndicatorsInfoList, businessIndicatorsInfoList, appraisalIndexList, initBase, tokenOrg);
//            unitDetail(initBaseVO, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }else if(VIRTUAL_ORG_TYPE.equals(tokenOrg.getType())){
//            List<BusinessIndicatorsInfo> businessIndicatorsInfoList = new ArrayList<>();
//            virtualInfoInit(mainIndicatorsInfoList, businessIndicatorsInfoList, appraisalIndexList, initBase, tokenOrg);
//            virtualDetail(initBaseVO, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }else {
//            // 二级企业
//            if (CollectionUtil.isNotEmpty(orgService.getChildOrg(tokenOrgId))){
//                mainIndicatorsInfoList.addAll(initMainIndicatorsInfo(appraisalIndexList, initBase.getId(),
//                        tokenOrg.getId(), tokenOrg.getName(), initBase.getFillingYear(), GROUP));
//            }else {
//                mainIndicatorsInfoList.addAll(initMainIndicatorsInfo(appraisalIndexList, initBase.getId(),
//                        tokenOrg.getId(), tokenOrg.getName(), initBase.getFillingYear(), SINGLE));
//            }
//            initBaseVO.setMainIndicatorsInfoVOS(mainIndicatorsInfoWrapper.entityToVO(mainIndicatorsInfoList));
//            mainIndicatorsInfoService.saveBatch(mainIndicatorsInfoList);
//        }
//
//        return initBaseVO;
//    }
//
//    /**
//     * 集团节点初始化
//     * @param mainIndicatorsInfoList
//     * @param businessIndicatorsInfoList
//     * @param appraisalIndexList
//     * @param baseMainIndicators
//     * @param unitOrg
//     */
//    private void unitInfoInit(List<MainIndicatorsInfo> mainIndicatorsInfoList, List<BusinessIndicatorsInfo> businessIndicatorsInfoList,
//                              List<AppraisalIndex> appraisalIndexList, BaseMainIndicators baseMainIndicators, Org unitOrg){
//        mainIndicatorsInfoList.addAll(initMainIndicatorsInfo(appraisalIndexList, baseMainIndicators.getId(),
//                unitOrg.getId(), SUMMARY_NAME, baseMainIndicators.getFillingYear(), GROUP));
//        mainIndicatorsInfoList.addAll(initMainIndicatorsInfo(appraisalIndexList, baseMainIndicators.getId(),
//                unitOrg.getId(), unitOrg.getName(), baseMainIndicators.getFillingYear(), SINGLE));
//
//        List<Org> childOrgList = orgService.getChildOrg(unitOrg.getId());
//        Map<String, Org> childOrgMap = childOrgList.stream().collect(Collectors.toMap(Org::getId, childOrg -> childOrg));
//        List<BaseMainIndicators> childBaseList = list(Wrappers.<BaseMainIndicators>lambdaQuery()
//                .eq(BaseMainIndicators::getFillingYear, baseMainIndicators.getFillingYear())
//                .in(BaseMainIndicators::getFillingUnitId, childOrgMap.keySet()));
//        if (CollectionUtil.isNotEmpty(childBaseList)){
//            Map<Long, BaseMainIndicators> childBaseMap = childBaseList.stream().collect(Collectors.toMap(BaseMainIndicators::getId, childBase -> childBase));
//            Set<Long> baseIds = childBaseMap.keySet();
//            List<MainIndicatorsInfo> childMainIndicatorsInfoList =  mainIndicatorsInfoService
//                    .list(Wrappers.<MainIndicatorsInfo>lambdaQuery().in(MainIndicatorsInfo::getBaseId, baseIds));
//            List<BusinessIndicatorsInfo> childBusinessIndicatorsInfoList =  businessIndicatorsInfoService
//                    .list(Wrappers.<BusinessIndicatorsInfo>lambdaQuery().in(BusinessIndicatorsInfo::getBaseId, baseIds));
//            if (CollectionUtil.isNotEmpty(childMainIndicatorsInfoList)){
//                Map<Long, List<MainIndicatorsInfo>> childMainIndicatorsInfoMap = childMainIndicatorsInfoList.stream()
//                        .collect(Collectors.groupingBy(MainIndicatorsInfo::getBaseId));
//                childMainIndicatorsInfoMap.forEach((k, childList) -> {
//                    for (MainIndicatorsInfo mainIndicatorsInfo : childList){
//                        mainIndicatorsInfo.setId(null);
//                        mainIndicatorsInfo.setOrgId(childBaseMap.get(mainIndicatorsInfo.getBaseId()).getFillingUnitId());
//                        mainIndicatorsInfo.setOrgName(childOrgMap.get(mainIndicatorsInfo.getOrgId()).getName());
//                        mainIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                        mainIndicatorsInfoList.add(mainIndicatorsInfo);
//                    }
//                });
//            }
//
//            if (CollectionUtil.isNotEmpty(childBusinessIndicatorsInfoList)){
//                Map<Long, List<BusinessIndicatorsInfo>> childBusinessIndicatorsInfoMap = childBusinessIndicatorsInfoList.stream()
//                        .collect(Collectors.groupingBy(BusinessIndicatorsInfo::getBaseId));
//                childBusinessIndicatorsInfoMap.forEach((k, childList) -> {
//                    for (BusinessIndicatorsInfo businessIndicatorsInfo : childList){
//                        businessIndicatorsInfo.setId(null);
//                        businessIndicatorsInfo.setOrgId(childBaseMap.get(businessIndicatorsInfo.getBaseId()).getFillingUnitId());
//                        businessIndicatorsInfo.setOrgName(childOrgMap.get(businessIndicatorsInfo.getOrgId()).getName());
//                        businessIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                        businessIndicatorsInfo.setTrendChange(BigDecimalUtil.divide(BigDecimalUtil.subtract(businessIndicatorsInfo.getBudgetValue(),
//                                businessIndicatorsInfo.getLastCompleteValue()), businessIndicatorsInfo.getLastCompleteValue(), 2, BigDecimal.ROUND_HALF_UP, 100 ));
//                        businessIndicatorsInfoList.add(businessIndicatorsInfo);
//                    }
//                });
//                businessIndicatorsInfoService.saveBatch(businessIndicatorsInfoList);
//            }
//        }
//        mainIndicatorsInfoService.saveBatch(mainIndicatorsInfoList);
//    }
//
//    /**
//     * 虚拟节点初始化 广电合并 城投合并
//     * @param mainIndicatorsInfoList
//     * @param businessIndicatorsInfoList
//     * @param appraisalIndexList
//     * @param baseMainIndicators
//     * @param virtualOrg
//     */
//    private void virtualInfoInit(List<MainIndicatorsInfo> mainIndicatorsInfoList, List<BusinessIndicatorsInfo> businessIndicatorsInfoList,
//                              List<AppraisalIndex> appraisalIndexList, BaseMainIndicators baseMainIndicators, Org virtualOrg){
//        List<Org> childUnitOrgList = orgService.getChildOrg(virtualOrg.getId());
//        mainIndicatorsInfoList.addAll(virtualInitMainIndicatorsInfo(appraisalIndexList, baseMainIndicators.getId(),
//                virtualOrg.getId(), virtualOrg.getName(), baseMainIndicators.getFillingYear(), childUnitOrgList));
//
//        Map<String, Org> childOrgMap = childUnitOrgList.stream().collect(Collectors.toMap(Org::getId, childOrg -> childOrg));
//        List<BaseMainIndicators> childBaseList = list(Wrappers.<BaseMainIndicators>lambdaQuery()
//                .eq(BaseMainIndicators::getFillingYear, baseMainIndicators.getFillingYear())
//                .in(BaseMainIndicators::getFillingUnitId, childOrgMap.keySet()));
//        if (CollectionUtil.isNotEmpty(childBaseList)){
//            Map<Long, BaseMainIndicators> childBaseMap = childBaseList.stream().collect(Collectors.toMap(BaseMainIndicators::getId, childBase -> childBase));
//            Set<Long> baseIds = childBaseMap.keySet();
//            List<MainIndicatorsInfo> childMainIndicatorsInfoList =  mainIndicatorsInfoService
//                    .list(Wrappers.<MainIndicatorsInfo>lambdaQuery().in(MainIndicatorsInfo::getBaseId, baseIds));
//            List<BusinessIndicatorsInfo> childBusinessIndicatorsInfoList =  businessIndicatorsInfoService
//                    .list(Wrappers.<BusinessIndicatorsInfo>lambdaQuery().in(BusinessIndicatorsInfo::getBaseId, baseIds));
//            if (CollectionUtil.isNotEmpty(childMainIndicatorsInfoList)){
//                Map<Long, List<MainIndicatorsInfo>> childMainIndicatorsInfoMap = childMainIndicatorsInfoList.stream()
//                        .collect(Collectors.groupingBy(MainIndicatorsInfo::getBaseId));
//                childMainIndicatorsInfoMap.forEach((k, childList) -> {
//                    for (MainIndicatorsInfo mainIndicatorsInfo : childList){
//                        if (SUMMARY_NAME.equals(mainIndicatorsInfo.getOrgName())){
//                            mainIndicatorsInfo.setOrgName(childOrgMap.get(mainIndicatorsInfo.getOrgId()).getName() + StringPool.DASH + SUMMARY_NAME);
//                        }
//                        mainIndicatorsInfo.setId(null);
//                        mainIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                        mainIndicatorsInfoList.add(mainIndicatorsInfo);
//                    }
//                });
//            }
//            mainIndicatorsInfoService.saveBatch(mainIndicatorsInfoList);
//
//            if (CollectionUtil.isNotEmpty(childBusinessIndicatorsInfoList)){
//                Map<Long, List<BusinessIndicatorsInfo>> childBusinessIndicatorsInfoMap = childBusinessIndicatorsInfoList.stream()
//                        .collect(Collectors.groupingBy(BusinessIndicatorsInfo::getBaseId));
//                childBusinessIndicatorsInfoMap.forEach((k, childList) -> {
//                    for (BusinessIndicatorsInfo businessIndicatorsInfo : childList){
//                        businessIndicatorsInfo.setId(null);
//                        businessIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                        businessIndicatorsInfoList.add(businessIndicatorsInfo);
//                    }
//                });
//                businessIndicatorsInfoService.saveBatch(businessIndicatorsInfoList);
//            }
//        }
//    }
//
//    /**
//     * 集团详情
//     * @return
//     */
//    private BaseMainIndicatorsVO unitDetail(BaseMainIndicatorsVO baseMainIndicatorsVO,
//                                            List<MainIndicatorsInfo> mainIndicatorsInfoList,
//                                            List<BusinessIndicatorsInfo> businessIndicatorsInfoList){
//        if (CollectionUtil.isNotEmpty(mainIndicatorsInfoList)){
//            Map<String, List<MainIndicatorsInfo>> mainIndicatorsInfoMap = mainIndicatorsInfoList.stream()
//                    .collect(Collectors.groupingBy(mainIndicatorsInfo -> mainIndicatorsInfo.getOrgId() + StringPool.DASH + mainIndicatorsInfo.getOrgName()));
//            String firstKey = baseMainIndicatorsVO.getFillingUnitId() + StringPool.DASH + SUMMARY_NAME;
//            String secondKey = baseMainIndicatorsVO.getFillingUnitId() + StringPool.DASH + baseMainIndicatorsVO.getFillingUnitName();
//            List<MainIndicatorsInfo> firstList = mainIndicatorsInfoMap.get(firstKey);
//            List<MainIndicatorsInfo> secondList = mainIndicatorsInfoMap.get(secondKey);
//            List<HeaderVO> mainIndicatorsHead = new ArrayList<>();
//            mainIndicatorsHead.add(HeaderVO.builder().key("orgName").title("公司名称").build());
//            firstList.sort(Comparator.comparing(MainIndicatorsInfo::getSort));
//            List<String> indexIdList = new ArrayList<>();
//            List<String> indexNameList = new ArrayList<>();
//            for (MainIndicatorsInfo mainIndicatorsInfo : firstList){
//                List<HeaderVO> childHeadList = new ArrayList<>();
//                Long indexId = mainIndicatorsInfo.getAppraisalIndexId();
//                childHeadList.add(HeaderVO.builder()
//                        .key(indexId + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)
//                        .title("上年执行数").build());
//                childHeadList.add(HeaderVO.builder().key(indexId + StringPool.DASH + BUDGET_VALUE_KEY).title("当年预算数").build());
//                childHeadList.add(HeaderVO.builder().key(indexId + StringPool.DASH + TREND_CHANGE_KEY).title("变动趋势").build());
//                mainIndicatorsHead.add(HeaderVO.builder()
//                        .title(mainIndicatorsInfo.getAppraisalIndexName()).children(childHeadList).build());
//                indexIdList.add(String.valueOf(mainIndicatorsInfo.getAppraisalIndexId()));
//                indexNameList.add(mainIndicatorsInfo.getAppraisalIndexName());
//            }
//            baseMainIndicatorsVO.setMainIndexId(indexIdList);
//            baseMainIndicatorsVO.setMainIndexName(indexNameList);
//            List<Map<String, Object>> mainIndicatorsResultsList = new ArrayList<>();
//            mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, baseMainIndicatorsVO.getFillingUnitId(), SUMMARY_NAME, firstList));
//            mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, baseMainIndicatorsVO.getFillingUnitId(),
//                    baseMainIndicatorsVO.getFillingUnitName(), secondList));
//            List<MainIndicatorsInfo> childChangeList = new ArrayList<>();
//            mainIndicatorsInfoMap.forEach((k, v) -> {
//                if (k.equals(firstKey) || k.equals(secondKey)){
//                    return;
//                }
//                for (MainIndicatorsInfo mainIndicatorsInfo : v){
//                    if (StringUtil.isNotBlank(mainIndicatorsInfo.getChangeReason())){
//                        childChangeList.add(mainIndicatorsInfo);
//                    }
//                }
//                String[] strList = k.split(StringPool.DASH);
//                mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, strList[0], strList[1], v));
//            });
//            baseMainIndicatorsVO.setMainIndicatorsInfoChangeVOS(mainIndicatorsInfoWrapper.entityToVO(childChangeList));
//            baseMainIndicatorsVO.setUnitMainIndicatorsHeadList(mainIndicatorsHead);
//            baseMainIndicatorsVO.setUnitMainIndicatorsInfoList(mainIndicatorsResultsList);
//        }
//
//        if (CollectionUtil.isNotEmpty(businessIndicatorsInfoList)){
//            Map<String, List<BusinessIndicatorsInfo>> businessIndicatorsInfoMap = businessIndicatorsInfoList.stream()
//                    .collect(Collectors.groupingBy(businessIndicatorsInfo -> businessIndicatorsInfo.getOrgId() + StringPool.DASH + businessIndicatorsInfo.getOrgName()));
//            List<String> businessIndicatorsKeyList = new ArrayList<>();
//            List<String> businessIndexNameList = new ArrayList<>();
//            List<String> businessIndexUnitList = new ArrayList<>();
//            List<Map<String, Object>> businessIndicatorsResultsList = new ArrayList<>();
//            businessIndicatorsInfoMap.forEach((k, v) -> {
//                String[] strList = k.split(StringPool.DASH);
//                Map<String, Object> map = new HashMap<>();
//                map.put(ORG_ID_KEY, strList[0]);
//                map.put(ORG_NAME_KEY, strList[1]);
//                for (BusinessIndicatorsInfo businessIndicatorsInfo : v){
//                    String businessIndicatorsKey = businessIndicatorsInfo.getBusinessIndicatorsName()
//                            + StringPool.LEFT_BRACKET + businessIndicatorsInfo.getIndexUnit() + StringPool.RIGHT_BRACKET;
//                    if (!businessIndicatorsKeyList.contains(businessIndicatorsKey)){
//                        businessIndicatorsKeyList.add(businessIndicatorsKey);
//                        businessIndexNameList.add(businessIndicatorsInfo.getBusinessIndicatorsName());
//                        businessIndexUnitList.add(businessIndicatorsInfo.getIndexUnit());
//                    }
//                    map.put(businessIndicatorsKey + StringPool.DASH + LAST_COMPLETE_VALUE_KEY,  businessIndicatorsInfo.getLastCompleteValue());
//                    map.put(businessIndicatorsKey + StringPool.DASH + BUDGET_VALUE_KEY,  businessIndicatorsInfo.getBudgetValue());
//                    map.put(businessIndicatorsKey + StringPool.DASH + TREND_CHANGE_KEY,  businessIndicatorsInfo.getTrendChange());
//                    map.put(businessIndicatorsKey + StringPool.DASH + CHANGE_REASON_KEY, businessIndicatorsInfo.getChangeReason());
//                }
//                businessIndicatorsResultsList.add(map);
//            });
//            baseMainIndicatorsVO.setBusinessIndexName(businessIndexNameList);
//            baseMainIndicatorsVO.setBusinessIndexUnit(businessIndexUnitList);
//            List<HeaderVO> businessIndicatorsHead = new ArrayList<>();
//            businessIndicatorsHead.add(HeaderVO.builder().key("orgName").title("公司名称").build());
//            for (String businessIndicatorsKey : businessIndicatorsKeyList){
//                List<HeaderVO> childHeadList = new ArrayList<>();
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + LAST_COMPLETE_VALUE_KEY).title("上年执行数").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + BUDGET_VALUE_KEY).title("当年预算数").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + TREND_CHANGE_KEY).title("变动趋势").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + CHANGE_REASON_KEY).title("原因说明").build());
//                businessIndicatorsHead.add(HeaderVO.builder()
//                        .title(businessIndicatorsKey).children(childHeadList).build());
//            }
//            baseMainIndicatorsVO.setUnitBusinessIndicatorsHeadList(businessIndicatorsHead);
//            baseMainIndicatorsVO.setUnitBusinessIndicatorsInfoList(businessIndicatorsResultsList);
//        }
//        return baseMainIndicatorsVO;
//    }
//
//    /**
//     * 虚拟节点详情
//     * @return
//     */
//    private BaseMainIndicatorsVO virtualDetail(BaseMainIndicatorsVO baseMainIndicatorsVO,
//                                            List<MainIndicatorsInfo> mainIndicatorsInfoList,
//                                            List<BusinessIndicatorsInfo> businessIndicatorsInfoList){
//        if (CollectionUtil.isNotEmpty(mainIndicatorsInfoList)){
//            Map<String, List<MainIndicatorsInfo>> mainIndicatorsInfoMap = mainIndicatorsInfoList.stream()
//                    .collect(Collectors.groupingBy(mainIndicatorsInfo -> mainIndicatorsInfo.getOrgId() + StringPool.DASH + mainIndicatorsInfo.getOrgName()));
//            String virtualKey = baseMainIndicatorsVO.getFillingUnitId() + StringPool.DASH + baseMainIndicatorsVO.getFillingUnitName();
//            List<MainIndicatorsInfo> virtualList = mainIndicatorsInfoMap.get(virtualKey);
//            List<HeaderVO> mainIndicatorsHead = new ArrayList<>();
//            mainIndicatorsHead.add(HeaderVO.builder().key("orgName").title("公司名称").build());
//            virtualList.sort(Comparator.comparing(MainIndicatorsInfo::getSort));
//            List<String> indexIdList = new ArrayList<>();
//            List<String> indexNameList = new ArrayList<>();
//            for (MainIndicatorsInfo mainIndicatorsInfo : virtualList){
//                List<HeaderVO> childHeadList = new ArrayList<>();
//                Long indexId = mainIndicatorsInfo.getAppraisalIndexId();
//                childHeadList.add(HeaderVO.builder()
//                        .key(indexId + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)
//                        .title("上年执行数").build());
//                childHeadList.add(HeaderVO.builder().key(indexId + StringPool.DASH + BUDGET_VALUE_KEY).title("当年预算数").build());
//                childHeadList.add(HeaderVO.builder().key(indexId + StringPool.DASH + TREND_CHANGE_KEY).title("变动趋势").build());
//                mainIndicatorsHead.add(HeaderVO.builder()
//                        .title(mainIndicatorsInfo.getAppraisalIndexName()).children(childHeadList).build());
//                indexIdList.add(String.valueOf(mainIndicatorsInfo.getAppraisalIndexId()));
//                indexNameList.add(mainIndicatorsInfo.getAppraisalIndexName());
//            }
//            baseMainIndicatorsVO.setMainIndexId(indexIdList);
//            baseMainIndicatorsVO.setMainIndexName(indexNameList);
//            List<Map<String, Object>> mainIndicatorsResultsList = new ArrayList<>();
//            mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, baseMainIndicatorsVO.getFillingUnitId(),
//                    baseMainIndicatorsVO.getFillingUnitName(), virtualList));
//            List<Org> childUnitOrg = orgService.getChildOrg(baseMainIndicatorsVO.getFillingUnitId());
//            List<String> keyList = new ArrayList<>();
//            keyList.add(virtualKey);
//            for (Org unitOrg : childUnitOrg){
//                String firstKey = unitOrg.getId() + StringPool.DASH + unitOrg.getName() + StringPool.DASH +  SUMMARY_NAME;
//                String secondKey = unitOrg.getId() + StringPool.DASH + unitOrg.getName();
//                keyList.add(firstKey);
//                keyList.add(secondKey);
//                List<MainIndicatorsInfo> firstList = mainIndicatorsInfoMap.get(firstKey);
//                List<MainIndicatorsInfo> secondList = mainIndicatorsInfoMap.get(secondKey);
//                mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, unitOrg.getId(),
//                        unitOrg.getName() + StringPool.DASH +  SUMMARY_NAME, firstList));
//                mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, unitOrg.getId(), unitOrg.getName(), secondList));
//            }
//            List<MainIndicatorsInfo> childChangeList = new ArrayList<>();
//            mainIndicatorsInfoMap.forEach((k, v) -> {
//                if (keyList.contains(k)){
//                    return;
//                }
//                for (MainIndicatorsInfo mainIndicatorsInfo : v){
//                    if (StringUtil.isNotBlank(mainIndicatorsInfo.getChangeReason())){
//                        childChangeList.add(mainIndicatorsInfo);
//                    }
//                }
//                String[] strList = k.split(StringPool.DASH);
//                mainIndicatorsResultsList.add(mainIndicatorsInfoListToMap(indexIdList, strList[0], strList[1], v));
//            });
//            baseMainIndicatorsVO.setMainIndicatorsInfoChangeVOS(mainIndicatorsInfoWrapper.entityToVO(childChangeList));
//            baseMainIndicatorsVO.setUnitMainIndicatorsHeadList(mainIndicatorsHead);
//            baseMainIndicatorsVO.setUnitMainIndicatorsInfoList(mainIndicatorsResultsList);
//        }
//
//        if (CollectionUtil.isNotEmpty(businessIndicatorsInfoList)){
//            Map<String, List<BusinessIndicatorsInfo>> businessIndicatorsInfoMap = businessIndicatorsInfoList.stream()
//                    .collect(Collectors.groupingBy(businessIndicatorsInfo -> businessIndicatorsInfo.getOrgId() + StringPool.DASH + businessIndicatorsInfo.getOrgName()));
//            List<String> businessIndicatorsKeyList = new ArrayList<>();
//            List<String> businessIndexNameList = new ArrayList<>();
//            List<String> businessIndexUnitList = new ArrayList<>();
//            List<Map<String, Object>> businessIndicatorsResultsList = new ArrayList<>();
//            businessIndicatorsInfoMap.forEach((k, v) -> {
//                String[] strList = k.split(StringPool.DASH);
//                Map<String, Object> map = new HashMap<>();
//                map.put(ORG_ID_KEY, strList[0]);
//                map.put(ORG_NAME_KEY, strList[1]);
//                for (BusinessIndicatorsInfo businessIndicatorsInfo : v){
//                    String businessIndicatorsKey = businessIndicatorsInfo.getBusinessIndicatorsName()
//                            + StringPool.LEFT_BRACKET + businessIndicatorsInfo.getIndexUnit() + StringPool.RIGHT_BRACKET;
//                    if (!businessIndicatorsKeyList.contains(businessIndicatorsKey)){
//                        businessIndicatorsKeyList.add(businessIndicatorsKey);
//                        businessIndexNameList.add(businessIndicatorsInfo.getBusinessIndicatorsName());
//                        businessIndexUnitList.add(businessIndicatorsInfo.getIndexUnit());
//                    }
//                    map.put(businessIndicatorsKey + StringPool.DASH + LAST_COMPLETE_VALUE_KEY,  businessIndicatorsInfo.getLastCompleteValue());
//                    map.put(businessIndicatorsKey + StringPool.DASH + BUDGET_VALUE_KEY,  businessIndicatorsInfo.getBudgetValue());
//                    map.put(businessIndicatorsKey + StringPool.DASH + TREND_CHANGE_KEY,  businessIndicatorsInfo.getTrendChange());
//                    map.put(businessIndicatorsKey + StringPool.DASH + CHANGE_REASON_KEY, businessIndicatorsInfo.getChangeReason());
//                }
//                businessIndicatorsResultsList.add(map);
//            });
//            baseMainIndicatorsVO.setBusinessIndexName(businessIndexNameList);
//            baseMainIndicatorsVO.setBusinessIndexUnit(businessIndexUnitList);
//            List<HeaderVO> businessIndicatorsHead = new ArrayList<>();
//            businessIndicatorsHead.add(HeaderVO.builder().key("orgName").title("公司名称").build());
//            for (String businessIndicatorsKey : businessIndicatorsKeyList){
//                List<HeaderVO> childHeadList = new ArrayList<>();
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + LAST_COMPLETE_VALUE_KEY).title("上年执行数").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + BUDGET_VALUE_KEY).title("当年预算数").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + TREND_CHANGE_KEY).title("变动趋势").build());
//                childHeadList.add(HeaderVO.builder().key(businessIndicatorsKey + StringPool.DASH + CHANGE_REASON_KEY).title("原因说明").build());
//                businessIndicatorsHead.add(HeaderVO.builder()
//                        .title(businessIndicatorsKey).children(childHeadList).build());
//            }
//            baseMainIndicatorsVO.setUnitBusinessIndicatorsHeadList(businessIndicatorsHead);
//            baseMainIndicatorsVO.setUnitBusinessIndicatorsInfoList(businessIndicatorsResultsList);
//        }
//        return baseMainIndicatorsVO;
//    }
//
//    private Map<String, Object> mainIndicatorsInfoListToMap(List<String> indexIdList, String orgId, String orgName, List<MainIndicatorsInfo> mainIndicatorsInfoList){
//        Map<String, Object> map = new HashMap<>();
//        Map<String, MainIndicatorsInfo> mainIndicatorsInfoMap = mainIndicatorsInfoList.stream()
//                .collect(Collectors.toMap(info -> String.valueOf(info.getAppraisalIndexId()), mainIndicatorsInfo -> mainIndicatorsInfo));
//        map.put(ORG_ID_KEY, orgId);
//        map.put(ORG_NAME_KEY, orgName);
//        for (String indexId : indexIdList){
//            if (mainIndicatorsInfoMap.containsKey(indexId)){
//                MainIndicatorsInfo mainIndicatorsInfo = mainIndicatorsInfoMap.get(indexId);
//                map.put(indexId + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY,  mainIndicatorsInfo.getBeforeLastCompleteValue());
//                map.put(indexId + StringPool.DASH + LAST_COMPLETE_VALUE_KEY,  mainIndicatorsInfo.getLastCompleteValue());
//                map.put(indexId + StringPool.DASH + BUDGET_VALUE_KEY,  mainIndicatorsInfo.getBudgetValue());
//                map.put(indexId + StringPool.DASH + TREND_CHANGE_KEY,  mainIndicatorsInfo.getTrendChange());
//                map.put(indexId + StringPool.DASH + CHANGE_REASON_KEY, mainIndicatorsInfo.getChangeReason());
//            }
//        }
//        return map;
//    }
//
//    /**
//     * 预算主要指标初始化
//     * @param appraisalIndexList
//     * @param baseId
//     * @param orgId
//     * @param orgName
//     * @param fillingYear
//     * @param isGroup 0单户 1合并
//     * @return
//     */
//    private List<MainIndicatorsInfo> initMainIndicatorsInfo(List<AppraisalIndex> appraisalIndexList, Long baseId,
//                                                            String orgId, String orgName, String fillingYear, int isGroup){
//        List<MainIndicatorsInfo> mainIndicatorsInfoList = new ArrayList<>();
//        List<String> codeList = appraisalIndexList.stream()
//                .filter(appraisalIndex -> StringUtil.isNotBlank(appraisalIndex.getCompleteCode()))
//                .map(AppraisalIndex::getCompleteCode).collect(Collectors.toList());
//        codeList.addAll(appraisalIndexList.stream()
//                .filter(appraisalIndex -> StringUtil.isNotBlank(appraisalIndex.getLastCompleteCode()))
//                .map(AppraisalIndex::getLastCompleteCode).collect(Collectors.toList()));
//        // 净资产收益率 临时处理后续从指标取数
//        codeList.add("K37");
//        codeList.add("KLAST37");
//        codeList.add("KLAST36");
//        List<AppraisalIndex> formulaIndexList = appraisalIndexList.stream()
//                .filter(appraisalIndex -> appraisalIndex.getIsFormula() != null && appraisalIndex.getIsFormula() == 1)
//                .collect(Collectors.toList());
//        IndicatorsValueDTO indicatorsValueDTO = new IndicatorsValueDTO();
//        int lastYear = Integer.valueOf(fillingYear) - 1;
//        indicatorsValueDTO.setCodes(codeList);
//        indicatorsValueDTO.setYear(String.valueOf(lastYear));
//        indicatorsValueDTO.setMonth(MAX_MONTH);
//        indicatorsValueDTO.setOrgId(orgId);
//        List<IndicatorsValueVO> indicatorsValueVOS = new ArrayList<>();
//        if (isGroup == 0){
//            indicatorsValueVOS = indicatorsValueMapper.querySingleValueByCode(indicatorsValueDTO);
//        }else {
//            indicatorsValueVOS = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        }
//
//        indicatorsValueDTO.setYear(String.valueOf(lastYear -1));
//        indicatorsValueDTO.setCode("KLAST37");
//        indicatorsValueDTO.setCodes(null);
//        List<IndicatorsValueVO> K37Value;
//        if (isGroup == 0){
//            K37Value = indicatorsValueMapper.querySingleValueByCode(indicatorsValueDTO);
//        }else {
//            K37Value = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        }
//
//        indicatorsValueDTO.setCode("KLAST36");
//        List<IndicatorsValueVO> K36Value;
//        if (isGroup == 0){
//            K36Value = indicatorsValueMapper.querySingleValueByCode(indicatorsValueDTO);
//        }else {
//            K36Value = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        }
//
//        Map<String, BigDecimal> valueCodeMap = indicatorsValueVOS.stream().collect(Collectors.toMap(IndicatorsValueVO::getCode, IndicatorsValueVO::getValue));
//
//        String kBeforeLAST37Key = "KBeforeLAST37";
//        valueCodeMap.put(kBeforeLAST37Key, new BigDecimal(0));
//        if (CollectionUtil.isNotEmpty(K37Value)){
//            valueCodeMap.put(kBeforeLAST37Key, K37Value.get(0).getValue());
//        }
//
//        String KBeforeLAST36KEY = "KBeforeLAST36";
//        valueCodeMap.put(KBeforeLAST36KEY, new BigDecimal(0));
//        if (CollectionUtil.isNotEmpty(K37Value)){
//            valueCodeMap.put(KBeforeLAST36KEY, K36Value.get(0).getValue());
//        }
//        OperationExpressionUtil operationExpressionUtil = new OperationExpressionUtil();
//        if (CollectionUtil.isNotEmpty(formulaIndexList)){
//            for (AppraisalIndex appraisalIndex : formulaIndexList){
//                valueCodeMap.put(appraisalIndex.getCompleteFormula(),
//                        new BigDecimal(operationExpressionUtil.operation(appraisalIndex.getCompleteFormula(), valueCodeMap, 6, BigDecimal.ROUND_HALF_UP)));
//                valueCodeMap.put(appraisalIndex.getLastCompleteFormula(),
//                        new BigDecimal(operationExpressionUtil.operation(appraisalIndex.getLastCompleteFormula(), valueCodeMap, 6, BigDecimal.ROUND_HALF_UP)));
//            }
//        }
//
//        for (AppraisalIndex appraisalIndex : appraisalIndexList){
//            MainIndicatorsInfo mainIndicatorsInfo = new MainIndicatorsInfo();
//            mainIndicatorsInfo.setOrgId(orgId);
//            mainIndicatorsInfo.setOrgName(orgName);
//            mainIndicatorsInfo.setAppraisalIndexId(appraisalIndex.getId());
//            mainIndicatorsInfo.setAppraisalIndexName(appraisalIndex.getName());
//            mainIndicatorsInfo.setBaseId(baseId);
//            if (appraisalIndex.getIsFormula() != null && appraisalIndex.getIsFormula() == 1){
//                mainIndicatorsInfo.setLastCompleteValue(valueCodeMap.get(appraisalIndex.getCompleteFormula()));
//                mainIndicatorsInfo.setBeforeLastCompleteValue(valueCodeMap.get(appraisalIndex.getLastCompleteFormula()));
//            }else {
//                mainIndicatorsInfo.setLastCompleteValue(valueCodeMap.get(appraisalIndex.getCompleteCode()));
//                mainIndicatorsInfo.setBeforeLastCompleteValue(valueCodeMap.get(appraisalIndex.getLastCompleteCode()));
//            }
//            mainIndicatorsInfo.setSort(appraisalIndex.getSort());
//            mainIndicatorsInfoList.add(mainIndicatorsInfo);
//        }
//        return mainIndicatorsInfoList;
//    }
//
//    /**
//     * 虚拟节点 预算主要指标初始化
//     * @param appraisalIndexList
//     * @param baseId
//     * @param orgId
//     * @param orgName
//     * @param fillingYear
//     * @param childUnitOrg
//     * @return
//     */
//    private List<MainIndicatorsInfo> virtualInitMainIndicatorsInfo(List<AppraisalIndex> appraisalIndexList, Long baseId,
//                                                            String orgId, String orgName, String fillingYear, List<Org> childUnitOrg){
//        List<MainIndicatorsInfo> mainIndicatorsInfoList = new ArrayList<>();
//        List<String> childUnitOrgIds = childUnitOrg.stream().map(Org::getId).collect(Collectors.toList());
//        List<String> codeList = appraisalIndexList.stream()
//                .filter(appraisalIndex -> StringUtil.isNotBlank(appraisalIndex.getCompleteCode()))
//                .map(AppraisalIndex::getCompleteCode).collect(Collectors.toList());
//        codeList.addAll(appraisalIndexList.stream()
//                .filter(appraisalIndex -> StringUtil.isNotBlank(appraisalIndex.getLastCompleteCode()))
//                .map(AppraisalIndex::getLastCompleteCode).collect(Collectors.toList()));
//        // 净资产收益率 临时处理后续从指标取数
//        codeList.add("K37");
//        codeList.add("KLAST37");
//        List<AppraisalIndex> formulaIndexList = appraisalIndexList.stream()
//                .filter(appraisalIndex -> appraisalIndex.getIsFormula() != null && appraisalIndex.getIsFormula() == 1)
//                .collect(Collectors.toList());
//        IndicatorsValueDTO indicatorsValueDTO = new IndicatorsValueDTO();
//        int lastYear = Integer.valueOf(fillingYear) - 1;
//        indicatorsValueDTO.setCodes(codeList);
//        indicatorsValueDTO.setYear(String.valueOf(lastYear));
//        indicatorsValueDTO.setMonth(MAX_MONTH);
//        indicatorsValueDTO.setOrgIds(childUnitOrgIds);
//        List<IndicatorsValueVO> indicatorsValueVOS = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        indicatorsValueDTO.setYear(String.valueOf(lastYear -1));
//        indicatorsValueDTO.setCode("KLAST37");
//        indicatorsValueDTO.setCodes(null);
//        List<IndicatorsValueVO> K37Value = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        Map<String, List<IndicatorsValueVO>> codeMap = indicatorsValueVOS.stream()
//                .collect(Collectors.groupingBy(IndicatorsValueVO::getCode));
//
//        Map<String, BigDecimal> valueCodeMap = new HashMap<>();
//        codeMap.forEach((k, v) -> {
//            BigDecimal summary = new BigDecimal(0);
//            for (IndicatorsValueVO indicatorsValueVO : v){
//                summary = BigDecimalUtil.add(summary, indicatorsValueVO.getValue());
//            }
//            valueCodeMap.put(k, summary);
//        });
//        String kBeforeLAST37Key = "KBeforeLAST37";
//        valueCodeMap.put(kBeforeLAST37Key, new BigDecimal(0));
//        if (CollectionUtil.isNotEmpty(K37Value)){
//            BigDecimal summary = new BigDecimal(0);
//            for (IndicatorsValueVO indicatorsValueVO : K37Value){
//                summary = BigDecimalUtil.add(summary, indicatorsValueVO.getValue());
//            }
//            valueCodeMap.put(kBeforeLAST37Key, summary);
//        }
//
//        indicatorsValueDTO.setCode("KLAST36");
//        indicatorsValueDTO.setCodes(null);
//        List<IndicatorsValueVO> K36Value = indicatorsValueMapper.queryGroupValueByCode(indicatorsValueDTO);
//        String kBeforeLAST36Key = "KBeforeLAST36";
//        valueCodeMap.put(kBeforeLAST36Key, new BigDecimal(0));
//        if (CollectionUtil.isNotEmpty(K37Value)){
//            BigDecimal summary = new BigDecimal(0);
//            for (IndicatorsValueVO indicatorsValueVO : K36Value){
//                summary = BigDecimalUtil.add(summary, indicatorsValueVO.getValue());
//            }
//            valueCodeMap.put(kBeforeLAST36Key, summary);
//        }
//
//        OperationExpressionUtil operationExpressionUtil = new OperationExpressionUtil();
//        if (CollectionUtil.isNotEmpty(formulaIndexList)){
//            for (AppraisalIndex appraisalIndex : formulaIndexList){
//                valueCodeMap.put(appraisalIndex.getCompleteFormula(),
//                        new BigDecimal(operationExpressionUtil.operation(appraisalIndex.getCompleteFormula(), valueCodeMap, 6, BigDecimal.ROUND_HALF_UP)));
//                valueCodeMap.put(appraisalIndex.getLastCompleteFormula(),
//                        new BigDecimal(operationExpressionUtil.operation(appraisalIndex.getLastCompleteFormula(), valueCodeMap, 6, BigDecimal.ROUND_HALF_UP)));
//            }
//        }
//
//        for (AppraisalIndex appraisalIndex : appraisalIndexList){
//            MainIndicatorsInfo mainIndicatorsInfo = new MainIndicatorsInfo();
//            mainIndicatorsInfo.setOrgId(orgId);
//            mainIndicatorsInfo.setOrgName(orgName);
//            mainIndicatorsInfo.setAppraisalIndexId(appraisalIndex.getId());
//            mainIndicatorsInfo.setAppraisalIndexName(appraisalIndex.getName());
//            mainIndicatorsInfo.setBaseId(baseId);
//            if (appraisalIndex.getIsFormula() != null && appraisalIndex.getIsFormula() == 1){
//                mainIndicatorsInfo.setLastCompleteValue(valueCodeMap.get(appraisalIndex.getCompleteFormula()));
//                mainIndicatorsInfo.setBeforeLastCompleteValue(valueCodeMap.get(appraisalIndex.getLastCompleteFormula()));
//            }else {
//                mainIndicatorsInfo.setLastCompleteValue(valueCodeMap.get(appraisalIndex.getCompleteCode()));
//                mainIndicatorsInfo.setBeforeLastCompleteValue(valueCodeMap.get(appraisalIndex.getLastCompleteCode()));
//            }
//            mainIndicatorsInfo.setSort(appraisalIndex.getSort());
//            mainIndicatorsInfoList.add(mainIndicatorsInfo);
//        }
//        return mainIndicatorsInfoList;
//    }
//
//    @Override
//    public BaseMainIndicators submit(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        boolean flag = false;
//        if (baseMainIndicatorsVO.getId() != null){
//            businessIndicatorsInfoService.remove(Wrappers.<BusinessIndicatorsInfo>lambdaQuery()
//                    .eq(BusinessIndicatorsInfo::getBaseId, baseMainIndicatorsVO.getId()));
//            mainIndicatorsInfoService.remove(Wrappers.<MainIndicatorsInfo>lambdaQuery()
//                    .eq(MainIndicatorsInfo::getBaseId, baseMainIndicatorsVO.getId()));
//        }else {
//            flag = true;
//        }
//        BaseMainIndicators baseMainIndicators = baseMainIndicatorsWrapper.voToEntity(baseMainIndicatorsVO);
//        baseMainIndicators.setFormType(String.valueOf(FR_MAIN_INDICATORS));
//        boolean result = saveOrUpdate(baseMainIndicators);
//        if (result){
//            formWorkflowService.startProcessAndSimulate(String.valueOf(baseMainIndicatorsVO.getId()), baseMainIndicatorsVO.getFormType(), new HashMap<>());
//            if (baseMainIndicatorsVO.getBaseType() == SECOND_ORG_BASE_TYPE){
//                if (CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getMainIndicatorsInfoVOS())){
//                    List<MainIndicatorsInfo> mainIndicatorsInfoList = mainIndicatorsInfoWrapper.voToEntity(baseMainIndicatorsVO.getMainIndicatorsInfoVOS());
//                    for (MainIndicatorsInfo mainIndicatorsInfo : mainIndicatorsInfoList){
//                        mainIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                    }
//                    mainIndicatorsInfoService.saveBatch(mainIndicatorsInfoList);
//                }
//
//                if (CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getBusinessIndicatorsInfoVOS())){
//                    List<BusinessIndicatorsInfo> businessIndicatorsInfoList = businessIndicatorsInfoWrapper.voToEntity(baseMainIndicatorsVO.getBusinessIndicatorsInfoVOS());
//                    for (BusinessIndicatorsInfo businessIndicatorsInfo : businessIndicatorsInfoList){
//                        businessIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                    }
//                    businessIndicatorsInfoService.saveBatch(businessIndicatorsInfoList);
//                }
//            }
//
//            if (baseMainIndicatorsVO.getBaseType() == UNIT_BASE_TYPE || baseMainIndicators.getBaseType() == VIRTUAL_ORG_BASE_TYPE){
//                if (CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getUnitMainIndicatorsInfoList())){
//                    List<MainIndicatorsInfo> mainIndicatorsInfoList = new ArrayList<>();
//                    for (Map<String, Object> map : baseMainIndicatorsVO.getUnitMainIndicatorsInfoList()){
//                        int i = 1;
//                        for (String indexId : baseMainIndicatorsVO.getMainIndexId()){
//                            MainIndicatorsInfo mainIndicatorsInfo = new MainIndicatorsInfo();
//                            mainIndicatorsInfo.setAppraisalIndexId(Long.valueOf(indexId));
//                            mainIndicatorsInfo.setAppraisalIndexName(baseMainIndicatorsVO.getMainIndexName().get(i-1));
//                            mainIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                            mainIndicatorsInfo.setOrgId((String)map.get(ORG_ID_KEY));
//                            mainIndicatorsInfo.setOrgName((String)map.get(ORG_NAME_KEY));
//                            mainIndicatorsInfo.setBeforeLastCompleteValue(BigDecimalUtil.objectToBigDecimal(map.get(indexId + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY)));
//                            mainIndicatorsInfo.setLastCompleteValue(BigDecimalUtil.objectToBigDecimal(map.get(indexId + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)));
//                            mainIndicatorsInfo.setBudgetValue(BigDecimalUtil.objectToBigDecimal(map.get(indexId + StringPool.DASH + BUDGET_VALUE_KEY)));
//                            mainIndicatorsInfo.setTrendChange(BigDecimalUtil.objectToBigDecimal(map.get(indexId + StringPool.DASH + TREND_CHANGE_KEY)));
//                            mainIndicatorsInfo.setChangeReason((String) map.get(indexId + StringPool.DASH + CHANGE_REASON_KEY));
//                            mainIndicatorsInfo.setSort(i);
//                            mainIndicatorsInfoList.add(mainIndicatorsInfo);
//                            i++;
//                        }
//                    }
//                    mainIndicatorsInfoService.saveBatch(mainIndicatorsInfoList);
//                }
//
//                if (CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getUnitBusinessIndicatorsInfoList())){
//                    List<BusinessIndicatorsInfo> businessIndicatorsInfoList = new ArrayList<>();
//                    for (Map<String, Object> map : baseMainIndicatorsVO.getUnitBusinessIndicatorsInfoList()){
//                        for (int i = 0; i< baseMainIndicatorsVO.getBusinessIndexName().size(); i++){
//                            BusinessIndicatorsInfo businessIndicatorsInfo = new BusinessIndicatorsInfo();
//                            businessIndicatorsInfo.setBaseId(baseMainIndicators.getId());
//                            businessIndicatorsInfo.setOrgId((String)map.get(ORG_ID_KEY));
//                            businessIndicatorsInfo.setOrgName((String)map.get(ORG_NAME_KEY));
//                            businessIndicatorsInfo.setBusinessIndicatorsName(baseMainIndicatorsVO.getBusinessIndexName().get(i));
//                            businessIndicatorsInfo.setIndexUnit(baseMainIndicatorsVO.getBusinessIndexUnit().get(i));
//                            String businessIndicatorsKey = baseMainIndicatorsVO.getBusinessIndexName().get(i)
//                                    + StringPool.LEFT_BRACKET + baseMainIndicatorsVO.getBusinessIndexUnit().get(i) + StringPool.RIGHT_BRACKET;
//                            businessIndicatorsInfo.setLastCompleteValue(BigDecimalUtil.objectToBigDecimal(map.get(businessIndicatorsKey + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)));
//                            businessIndicatorsInfo.setBudgetValue(BigDecimalUtil.objectToBigDecimal(map.get(businessIndicatorsKey + StringPool.DASH + BUDGET_VALUE_KEY)));
//                            businessIndicatorsInfo.setTrendChange(BigDecimalUtil.objectToBigDecimal(map.get(businessIndicatorsKey + StringPool.DASH + TREND_CHANGE_KEY)));
//                            businessIndicatorsInfo.setChangeReason((String) map.get(businessIndicatorsKey + StringPool.DASH + CHANGE_REASON_KEY));
//                            businessIndicatorsInfoList.add(businessIndicatorsInfo);
//                        }
//
//                    }
//                    businessIndicatorsInfoService.saveBatch(businessIndicatorsInfoList);
//                }
//            }
//        }
//
//        if (flag){
//            fileService.saveAll(String.valueOf(baseMainIndicators.getId()), baseMainIndicatorsVO.getDocList());
//        }else {
//            fileService.edit(String.valueOf(baseMainIndicators.getId()), baseMainIndicatorsVO.getDocList());
//        }
//        return baseMainIndicators;
//    }
//
//    @Override
//    public HashMap<String,Object> commit(String id) {
//        handleStatus(Long.valueOf(id), FormStatusConstant.FLOW, null);
//
//        //将需要提交的流程变量返回，用于工作流侧
//        return new HashMap<String,Object>();
//    }
//
//    @Override
//    public Boolean finish(String id) {
//        /**
//         * 设置审批人和审批时间
//         */
//        BaseMainIndicators baseMainIndicators = getById(id);
//        baseMainIndicators.setApprovedUser(TokenUtil.getTokenUserId());
//        Date now = DateUtil.now();
//        baseMainIndicators.setApprovedTime(now);
//        updateById(baseMainIndicators);
//        return handleStatus(Long.valueOf(id), FormStatusConstant.FINISH, "审批完成");
//    }
//
//    @Override
//    public Boolean reject(String id, int formState, String comment) {
//        return handleStatus(Long.valueOf(id), formState, comment);
//    }
//
//
//    @Override
//    public List<PageData> findByIds(List<String> formIds) {
//        LambdaQueryWrapper<BaseMainIndicators> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.in(BaseMainIndicators::getId, Func.toLongList(StringUtils.join(formIds, StringPool.COMMA)));
//        List<BaseMainIndicators> baseMainIndicators = list(queryWrapper);
//        List<BaseMainIndicatorsVO> subsidiaryMixedReformVOS = baseMainIndicatorsWrapper.entityToVO(baseMainIndicators);
//        List<PageData> pageDataList = new ArrayList<>();
//        try{
//            if (CollectionUtil.isNotEmpty(subsidiaryMixedReformVOS)){
//                for (BaseMainIndicatorsVO vo : subsidiaryMixedReformVOS){
//                    PageData pd = new PageData();
//                    pd.put("id", vo.getId());
//                    pd.put("UNITNAME", vo.getFillingUnitName());
//                    pd.put("APPLICANTNAME", vo.getCreateUserName());
//                    pd.put("applicantId", vo.getCreateUser());
//                    pd.put("applyOrganizationId", vo.getFillingUnitId());
//                    pd.put("formType", FR_MAIN_INDICATORS);
//                    pd.put("orgName", vo.getFillingUnitName());
//                    pageDataList.add(pd);
//                }
//            }
//
//            return pageDataList;
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//        return pageDataList;
//    }
//
//    @Override
//    public List<Integer> getFormType() {
//        return Arrays.asList(FR_MAIN_INDICATORS);
//    }
//
//
//    @Override
//    public void goBackToStash(String formId) {
//        Long id = Long.valueOf(formId);
//        BaseMainIndicators baseMainIndicators = getById(id);
//        if (baseMainIndicators.getStatus() == FormStatusConstant.FINISH){
//            LambdaUpdateWrapper<BaseMainIndicators> updateWrapper = new LambdaUpdateWrapper<>();
//            update(updateWrapper.eq(BaseMainIndicators::getId, id)
//                    .set(BaseMainIndicators::getApprovedUser, null).set(BaseMainIndicators::getApprovedTime, null));
//        }
//
//        handleStatus(Long.valueOf(formId), UNREVIEWED, null);
//    }
//
//    @Override
//    public BaseMainIndicatorsVO detail(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        BaseMainIndicators baseMainIndicators = getById(baseMainIndicatorsVO.getId());
//        if (baseMainIndicators == null){
//            throw new MyRuntimeException(new ObjResult("该单据不存在！"));
//        }
//        BaseMainIndicatorsVO detail = baseMainIndicatorsWrapper.entityToVO(baseMainIndicators);
//        List<BusinessIndicatorsInfo> businessIndicatorsInfoList = businessIndicatorsInfoService
//                .list(Wrappers.<BusinessIndicatorsInfo>lambdaQuery().eq(BusinessIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//        detail.setBusinessIndicatorsInfoVOS(businessIndicatorsInfoWrapper.entityToVO(businessIndicatorsInfoList));
//        List<MainIndicatorsInfo> mainIndicatorsInfoList = mainIndicatorsInfoService
//                .list(Wrappers.<MainIndicatorsInfo>lambdaQuery().eq(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//        Org org = orgService.getById(detail.getFillingUnitId());
//        detail.setFillingUnitName(org.getName());
//        String countDate = detail.getFillingYear() + "-12";
//        boolean unitFlag = IS_UNIT.equals(org.getIsUnit()) && (!orgService.getDTFlag(countDate) || !orgService.isDT(org.getId()));
//        if (unitFlag){
//            //集团
//            unitDetail(detail, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }else if (VIRTUAL_ORG_TYPE.equals(org.getType())){
//            virtualDetail(detail, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }else {
//            //二级子企业
//            detail.setMainIndicatorsInfoVOS(mainIndicatorsInfoWrapper.entityToVO(mainIndicatorsInfoList));
//            detail.setBusinessIndicatorsInfoVOS(businessIndicatorsInfoWrapper.entityToVO(businessIndicatorsInfoList));
//        }
//
//        return detail;
//    }
//
//    @Override
//    public BaseMainIndicatorsVO summary(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        BaseMainIndicators baseMainIndicators = getById(baseMainIndicatorsVO.getId());
//        if (baseMainIndicators == null){
//            throw new MyRuntimeException(new ObjResult("获取单据信息失败"));
//        }
//
//        String lastYear = String.valueOf(Integer.valueOf(baseMainIndicators.getFillingYear()) - 1);
//        List<AppraisalIndex> appraisalIndexList = appraisalIndexService
//                .listByTableCodeAndYear(AppraisalIndexConstant.MAIN_INDICATORS_CODE, lastYear);
//        if (CollectionUtil.isEmpty(appraisalIndexList)){
//            throw new MyRuntimeException(new ObjResult("指标配置信息获取失败"));
//        }
//
//        businessIndicatorsInfoService.remove(Wrappers.<BusinessIndicatorsInfo>lambdaQuery()
//                .in(BusinessIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//        mainIndicatorsInfoService.remove(Wrappers.<MainIndicatorsInfo>lambdaQuery()
//                .in(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//        Org org = orgService.getById(baseMainIndicators.getFillingUnitId());
//        BaseMainIndicatorsVO indicatorsVO = baseMainIndicatorsWrapper.entityToVO(baseMainIndicators);
//        indicatorsVO.setFillingUnitName(org.getName());
//        List<MainIndicatorsInfo> mainIndicatorsInfoList = new ArrayList<>();
//        List<BusinessIndicatorsInfo> businessIndicatorsInfoList = new ArrayList<>();
//        String countDate = baseMainIndicators.getFillingYear() + "-12";
//        boolean unitFlag = IS_UNIT.equals(org.getIsUnit()) && (!orgService.getDTFlag(countDate) || !orgService.isDT(org.getId()));
//        if (unitFlag){
//            unitInfoInit(mainIndicatorsInfoList, businessIndicatorsInfoList, appraisalIndexList, baseMainIndicators, org);
//            unitDetail(indicatorsVO, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }else if (VIRTUAL_ORG_TYPE.equals(org.getType())){
//            virtualInfoInit(mainIndicatorsInfoList, businessIndicatorsInfoList, appraisalIndexList, baseMainIndicators, org);
//            virtualDetail(indicatorsVO, mainIndicatorsInfoList, businessIndicatorsInfoList);
//        }
//        return indicatorsVO;
//    }
//
//    @Override
//    public ReportReturnVO detailsReport(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        if (StringUtil.isBlank(baseMainIndicatorsVO.getFillingYear())){
//            throw new MyRuntimeException(new ObjResult("年度为空！"));
//        }
//        String lastYear = String.valueOf(Integer.valueOf(baseMainIndicatorsVO.getFillingYear()) - 1);
//        String beforeYear = String.valueOf(Integer.valueOf(baseMainIndicatorsVO.getFillingYear()) - 2);
//        List<AppraisalIndex> appraisalIndexList = appraisalIndexService
//                .listByTableCodeAndYear(AppraisalIndexConstant.MAIN_INDICATORS_CODE, lastYear);
//        if (CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getAppraisalIndexIds())){
//            appraisalIndexList = appraisalIndexList.stream()
//                    .filter(appraisalIndex -> baseMainIndicatorsVO.getAppraisalIndexIds().contains(String.valueOf(appraisalIndex.getId()))).collect(Collectors.toList());
//        }
//        if (CollectionUtil.isEmpty(appraisalIndexList)){
//            throw new MyRuntimeException(new ObjResult("指标配置信息获取失败"));
//        }
//
//        List<HeaderVO> headerVOS = new ArrayList<>();
//        headerVOS.add(HeaderVO.builder().key("orgName").field("orgName").treeNode(true).title("企业名称").build());
//
//        for (AppraisalIndex appraisalIndex : appraisalIndexList){
//            List<HeaderVO> childHeadList = new ArrayList<>();
//            childHeadList.add(HeaderVO.builder()
//                    .key(appraisalIndex.getId() + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY)
//                    .field(appraisalIndex.getId() + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY)
//                    .title(beforeYear + "年").build());
//            childHeadList.add(HeaderVO.builder()
//                    .key(appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)
//                    .field(appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY)
//                    .title(lastYear + "年").build());
//            childHeadList.add(HeaderVO.builder()
//                    .key(appraisalIndex.getId() + StringPool.DASH + LAST_GROWTH_RATE_KEY)
//                    .field(appraisalIndex.getId() + StringPool.DASH + LAST_GROWTH_RATE_KEY)
//                    .title("增长率").build());
//            childHeadList.add(HeaderVO.builder()
//                    .key(appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY)
//                    .field(appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY)
//                    .title(baseMainIndicatorsVO.getFillingYear() + "年").build());
//            childHeadList.add(HeaderVO.builder()
//                    .key(appraisalIndex.getId() + StringPool.DASH + BUDGET_GROWTH_RATE_KEY)
//                    .field(appraisalIndex.getId() + StringPool.DASH + BUDGET_GROWTH_RATE_KEY)
//                    .title("增长率").build());
//            headerVOS.add(HeaderVO.builder()
//                    .key(appraisalIndex.getName())
//                    .title(appraisalIndex.getName()).children(childHeadList).build());
//        }
//
//        List<OrgVO> orgVOList = orgService.findMainIndicatorsOrgTree();
//        List<BaseMainIndicators> baseMainIndicatorsList = list(Wrappers.<BaseMainIndicators>lambdaQuery()
//                .eq(BaseMainIndicators::getFillingYear, baseMainIndicatorsVO.getFillingYear())
//                .eq(BaseMainIndicators::getStatus, FINISH));
//        Map<String, List<MainIndicatorsInfo>> orgIdValueMap = new HashMap<>();
//        if (CollectionUtil.isNotEmpty(baseMainIndicatorsList)){
//            List<MainIndicatorsInfo> mainIndicatorsInfoList = mainIndicatorsInfoService.list(Wrappers.<MainIndicatorsInfo>lambdaQuery()
//                    .in(MainIndicatorsInfo::getBaseId, baseMainIndicatorsList.stream().map(BaseMainIndicators::getId).collect(Collectors.toList())));
//            Map<Long, List<MainIndicatorsInfo>> mainIndicatorsInfoMap = mainIndicatorsInfoList.stream().collect(Collectors.groupingBy(MainIndicatorsInfo::getBaseId));
//            for (BaseMainIndicators baseMainIndicators : baseMainIndicatorsList){
//
//                if (baseMainIndicators.getBaseType() == 1){
//                    List<MainIndicatorsInfo> mainIndicatorsInfos = mainIndicatorsInfoMap.get(baseMainIndicators.getId());
//                    orgIdValueMap.putAll(mainIndicatorsInfos.stream().filter(mainIndicatorsInfo -> baseMainIndicators.getFillingUnitId().equals(mainIndicatorsInfo.getOrgId()))
//                            .collect(Collectors.groupingBy(indicatorsInfo -> indicatorsInfo.getOrgId() + StringPool.DASH + indicatorsInfo.getOrgName())));
//                }
//                if (baseMainIndicators.getBaseType() == 2){
//                    orgIdValueMap.put(baseMainIndicators.getFillingUnitId(), mainIndicatorsInfoMap.get(baseMainIndicators.getId()));
//                }
//                if (baseMainIndicators.getBaseType() == 3){
//                    List<MainIndicatorsInfo> mainIndicatorsInfos = mainIndicatorsInfoMap.get(baseMainIndicators.getId());
//                    orgIdValueMap.putAll(mainIndicatorsInfos.stream().filter(mainIndicatorsInfo -> baseMainIndicators.getFillingUnitId().equals(mainIndicatorsInfo.getOrgId()))
//                            .collect(Collectors.groupingBy(indicatorsInfo -> indicatorsInfo.getOrgId())));
//                }
//
//            }
//        }
//        ReportReturnVO reportReturnVO = new ReportReturnVO();
//        ReportVO reportVO = new ReportVO();
//        reportVO.setHeader(headerVOS);
//        reportVO.setData(infoToMapTree(baseMainIndicatorsVO.getFillingYear(), orgVOList, orgIdValueMap, appraisalIndexList, null));
//        reportReturnVO.setGrids(reportVO);
//        return reportReturnVO;
//    }
//
//    @Override
//    public List<AppraisalIndex> mainIndexList(String year) {
//        if (StringUtil.isBlank(year)){
//            year = String.valueOf(Integer.valueOf(DateUtil.format(DateUtil.now(), DateUtil.PATTERN_YEAR)) - 1);
//        }
//        return appraisalIndexService
//                .listByTableCodeAndYear(AppraisalIndexConstant.MAIN_INDICATORS_CODE, year);
//    }
//
//    @Override
//    public List<Map<String, Object>> trendChart(BaseMainIndicatorsVO baseMainIndicatorsVO) {
//        if (StringUtil.isBlank(baseMainIndicatorsVO.getFillingUnitId())){
//            throw new MyRuntimeException(new ObjResult("请选择单位！"));
//        }
//        if (StringUtil.isBlank(baseMainIndicatorsVO.getFillingYear())){
//            throw new MyRuntimeException(new ObjResult("年度为空！"));
//        }
//
//        if (gzwProperties.getReportId().equals(baseMainIndicatorsVO.getFillingUnitId())){
//            List<Org> orgList = orgService.findMainIndicatorsSummaryOrg();
//            List<String> orgIds = orgList.stream().map(Org::getId).collect(Collectors.toList());
//            List<BaseMainIndicators> baseMainIndicatorsList = list(Wrappers.<BaseMainIndicators>lambdaQuery()
//                    .eq(BaseMainIndicators::getFillingYear, baseMainIndicatorsVO.getFillingYear())
//                    .in(BaseMainIndicators::getFillingUnitId, orgIds)
//                    .eq(BaseMainIndicators::getStatus, FINISH));
//            if (CollectionUtil.isEmpty(baseMainIndicatorsList)){
//                return new ArrayList<>();
//            }
//            LambdaQueryWrapper<MainIndicatorsInfo> lambdaQueryWrapper = Wrappers.<MainIndicatorsInfo>lambdaQuery()
////                    .in(CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getAppraisalIndexIds()),
////                            MainIndicatorsInfo::getAppraisalIndexId, baseMainIndicatorsVO.getAppraisalIndexIds())
//                    .orderByAsc(MainIndicatorsInfo::getSort);
//            lambdaQueryWrapper.and(wrapper -> {
//                for (BaseMainIndicators baseMainIndicators : baseMainIndicatorsList){
//                    if (baseMainIndicators.getBaseType() == UNIT_BASE_TYPE){
//                        wrapper.or(w -> w.eq(MainIndicatorsInfo::getOrgId, baseMainIndicators.getFillingUnitId())
//                                .eq(MainIndicatorsInfo::getOrgName, SUMMARY_NAME).eq(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//                    }
//                    if (baseMainIndicators.getBaseType() == SECOND_ORG_BASE_TYPE){
//                        wrapper.or(w -> w.eq(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//                    }
//                    if (baseMainIndicators.getBaseType() == VIRTUAL_ORG_BASE_TYPE){
//                        wrapper.or(w -> w.eq(MainIndicatorsInfo::getOrgId, baseMainIndicators.getFillingUnitId())
//                                .eq(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//                    }
//                }
//            });
//            List<MainIndicatorsInfo> mainIndicatorsInfoList = mainIndicatorsInfoService.list(lambdaQueryWrapper);
//            if (CollectionUtil.isEmpty(mainIndicatorsInfoList)){
//                return new ArrayList<>();
//            }
//            return listToMapList(mainIndicatorsInfoList, baseMainIndicatorsVO.getFillingYear(), baseMainIndicatorsVO.getAppraisalIndexIds(), true);
//        }else {
//            BaseMainIndicators baseMainIndicators = getOne(Wrappers.<BaseMainIndicators>lambdaQuery()
//                    .eq(BaseMainIndicators::getFillingYear, baseMainIndicatorsVO.getFillingYear())
//                    .eq(BaseMainIndicators::getFillingUnitId, baseMainIndicatorsVO.getFillingUnitId())
//                    .eq(BaseMainIndicators::getStatus, FINISH));
//            if (baseMainIndicators == null){
//                return new ArrayList<>();
//            }
//            LambdaQueryWrapper<MainIndicatorsInfo> lambdaQueryWrapper = Wrappers.<MainIndicatorsInfo>lambdaQuery()
//                    .eq(MainIndicatorsInfo::getBaseId, baseMainIndicators.getId())
//                    .in(CollectionUtil.isNotEmpty(baseMainIndicatorsVO.getAppraisalIndexIds()),
//                            MainIndicatorsInfo::getAppraisalIndexId, baseMainIndicatorsVO.getAppraisalIndexIds())
//                    .orderByAsc(MainIndicatorsInfo::getSort);
//            if (baseMainIndicators.getBaseType() == UNIT_BASE_TYPE){
//                lambdaQueryWrapper.eq(MainIndicatorsInfo::getOrgId, baseMainIndicators.getFillingUnitId())
//                        .eq(MainIndicatorsInfo::getOrgName, SUMMARY_NAME);
//            }
//            if (baseMainIndicators.getBaseType() == VIRTUAL_ORG_BASE_TYPE){
//                lambdaQueryWrapper.eq(MainIndicatorsInfo::getOrgId, baseMainIndicators.getFillingUnitId());
//            }
//            List<MainIndicatorsInfo> mainIndicatorsInfoList = mainIndicatorsInfoService.list(lambdaQueryWrapper);
//            if (CollectionUtil.isEmpty(mainIndicatorsInfoList)){
//                return new ArrayList<>();
//            }
//            return listToMapList(mainIndicatorsInfoList, baseMainIndicatorsVO.getFillingYear(),baseMainIndicatorsVO.getAppraisalIndexIds(), false);
//        }
//    }
//
//    @Override
//    public String export(Long id) {
//        BaseMainIndicators baseMainIndicators = getById(id);
//        if (baseMainIndicators == null){
//            throw new MyRuntimeException(new ObjResult("导出失败！"));
//        }
//
//        if (baseMainIndicators.getBaseType() == 2){
//            throw new MyRuntimeException(new ObjResult("该单据不支持导出！"));
//        }
//
//        String lastYear = String.valueOf(Integer.valueOf(baseMainIndicators.getFillingYear()) - 1);
//        List<AppraisalIndex> appraisalIndexList = appraisalIndexService
//                .listByTableCodeAndYear(AppraisalIndexConstant.MAIN_INDICATORS_CODE, lastYear);
//        Org org = orgService.getById(baseMainIndicators.getFillingUnitId());
//
//        List<MainIndicatorsInfo> infoList = mainIndicatorsInfoService
//                .list(Wrappers.<MainIndicatorsInfo>lambdaQuery().eq(MainIndicatorsInfo::getBaseId, id));
//        Map<String, List<MainIndicatorsInfo>> mainIndicatorsInfoMap = infoList.stream()
//                .collect(Collectors.groupingBy(mainIndicatorsInfo -> mainIndicatorsInfo.getOrgId() + StringPool.DASH + mainIndicatorsInfo.getOrgName()));
//        List<Map<String, Object>> dataMapList = new ArrayList<>();
//        //主要指标
//        if (baseMainIndicators.getBaseType() == 1){
//            //集团类型
//            String firstKey = baseMainIndicators.getFillingUnitId() + StringPool.DASH + SUMMARY_NAME;
//            String secondKey = baseMainIndicators.getFillingUnitId() + StringPool.DASH + org.getName();
//            List<MainIndicatorsInfo> firstList = mainIndicatorsInfoMap.get(firstKey);
//            List<MainIndicatorsInfo> secondList = mainIndicatorsInfoMap.get(secondKey);
//            dataMapList.add(infoListToExportMap(firstList, appraisalIndexList, SUMMARY_NAME));
//            dataMapList.add(infoListToExportMap(secondList, appraisalIndexList, org.getName()));
//            mainIndicatorsInfoMap.forEach((k, v) -> {
//                if (k.equals(firstKey) || k.equals(secondKey)){
//                    return;
//                }
//                String[] strList = k.split(StringPool.DASH);
//                dataMapList.add(infoListToExportMap(v, appraisalIndexList, strList[1]));
//            });
//        }
//        if (baseMainIndicators.getBaseType() == 3){
//            //虚拟节点
//            String virtualKey = baseMainIndicators.getFillingUnitId() + StringPool.DASH + org.getName();
//            List<MainIndicatorsInfo> virtualList = mainIndicatorsInfoMap.get(virtualKey);
//            dataMapList.add(infoListToExportMap(virtualList, appraisalIndexList, org.getName()));
//            List<Org> childUnitOrg = orgService.getChildOrg(baseMainIndicators.getFillingUnitId());
//            List<String> keyList = new ArrayList<>();
//            keyList.add(virtualKey);
//            int index = 2;
//            for (Org unitOrg : childUnitOrg){
//                String firstKey = unitOrg.getId() + StringPool.DASH + unitOrg.getName() + StringPool.DASH +  SUMMARY_NAME;
//                String secondKey = unitOrg.getId() + StringPool.DASH + unitOrg.getName();
//                keyList.add(firstKey);
//                keyList.add(secondKey);
//                List<MainIndicatorsInfo> firstList = mainIndicatorsInfoMap.get(firstKey);
//                List<MainIndicatorsInfo> secondList = mainIndicatorsInfoMap.get(secondKey);
//                dataMapList.add(infoListToExportMap(firstList, appraisalIndexList, unitOrg.getName() + StringPool.DASH +  SUMMARY_NAME));
//                dataMapList.add(infoListToExportMap(secondList, appraisalIndexList, unitOrg.getName()));
//                index = index + 2;
//            }
//            mainIndicatorsInfoMap.forEach((k, v) -> {
//                if (keyList.contains(k)){
//                    return;
//                }
//                String[] strList = k.split(StringPool.DASH);
//                dataMapList.add(infoListToExportMap(v, appraisalIndexList, strList[1]));
//            });
//        }
//
//        for (int i = 0; i < dataMapList.size(); i++){
//            Map<String, Object> dataMap  = dataMapList.get(i);
//            dataMap.put("index", i + 1);
//        }
//        Map<String, Object> baseMap = new HashMap<>(16);
//        //业务指标数据
//        List<BusinessIndicatorsInfo> businessIndicatorsInfoList = businessIndicatorsInfoService
//                .list(Wrappers.<BusinessIndicatorsInfo>lambdaQuery().eq(BusinessIndicatorsInfo::getBaseId, baseMainIndicators.getId()));
//        List<Map<String, Object>> bDataMapList = new ArrayList<>();
//        if (CollectionUtil.isNotEmpty(businessIndicatorsInfoList)){
//            List<String> businessKeyList = new ArrayList<>();
//            int i = 1;
//            for (BusinessIndicatorsInfo businessIndicatorsInfo : businessIndicatorsInfoList){
//                String businessKey =  businessIndicatorsInfo.getBusinessIndicatorsName()
//                        + StringPool.LEFT_BRACKET + businessIndicatorsInfo.getIndexUnit() + StringPool.RIGHT_BRACKET;
//                if (!businessKeyList.contains(businessKey)){
//                    businessKeyList.add(businessKey);
//                    baseMap.put("bName"+i, businessKey);
//                    i = i + 1;
//                }
//            }
//            Map<String, List<BusinessIndicatorsInfo>> businessMap = businessIndicatorsInfoList.stream().collect(Collectors.groupingBy(BusinessIndicatorsInfo::getOrgName));
//            businessMap.forEach((k, v) -> {
//                Map<String, BusinessIndicatorsInfo> keyMap = v.stream().collect(Collectors.toMap(businessIndicatorsInfo -> businessIndicatorsInfo.getBusinessIndicatorsName()
//                        + StringPool.LEFT_BRACKET + businessIndicatorsInfo.getIndexUnit() + StringPool.RIGHT_BRACKET, businessIndicatorsInfo -> businessIndicatorsInfo));
//                Map<String, Object> map = new HashMap<>();
//                map.put("orgName", k);
//                for (int j = 0; j < appraisalIndexList.size() ; j++){
//                    map.put("v" + (2 * (j +1)), null);
//                    map.put("v" + (2 * (j +1) - 1), null);
//                    if (j < businessKeyList.size()){
//                        String key = businessKeyList.get(j);
//                        if (keyMap.containsKey(key)){
//                            BusinessIndicatorsInfo info = keyMap.get(key);
//                            map.put("v" + (2 * (j +1)), info.getBudgetValue());
//                            map.put("v" + (2 * (j +1) - 1), info.getLastCompleteValue());
//                        }
//                    }
//                }
//                bDataMapList.add(map);
//            });
//            for (int j = 0; j < bDataMapList.size(); j++){
//                Map<String, Object> dataMap  = bDataMapList.get(j);
//                dataMap.put("index", j + 1);
//            }
//        }
//
//        String fileKey = id + StringPool.DASH + UUID.randomUUID().toString().replace(StringPool.DASH, "");
//        String fileName = fileKey + ".xlsx";
//        String exportPath = environment.getProperty("excel.path");
//        InputStream inputStream = this.getClass().getResourceAsStream("/exceldemo/MainIndicatorsExport.xlsx");
//        ExcelWriter excelWriter = EasyExcel.write(exportPath + fileName).withTemplate(inputStream).build();
//        WriteSheet writeSheet = EasyExcel.writerSheet(0).build();
//
//        baseMap.put("unitName", org.getName());
//        baseMap.put("fillingYear", baseMainIndicators.getFillingYear());
//        baseMap.put("lastYear", lastYear);
//        excelWriter.fill(baseMap, writeSheet);
//        FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
//        excelWriter.fill(new FillWrapper("a", dataMapList), fillConfig, writeSheet);
//        excelWriter.fill(new FillWrapper("b", bDataMapList), fillConfig, writeSheet);
//        excelWriter.finish();
//        String excelName = baseMainIndicators.getFillingYear() + "主要预算指标";
//        redisUtils.set(fileKey, excelName, 10 * 60);
//        return fileKey;
//    }
//
//    private Map<String, Object> infoListToExportMap(List<MainIndicatorsInfo> infoList, List<AppraisalIndex> appraisalIndexList, String orgName){
//        Map<Long, MainIndicatorsInfo> infoMap = infoList.stream()
//                .collect(Collectors.toMap(MainIndicatorsInfo::getAppraisalIndexId, info -> info));
//        Map<String, Object> map = new HashMap<>();
//        map.put("orgName", orgName);
//        for (int i = 0; i < appraisalIndexList.size(); i++){
//            AppraisalIndex appraisalIndex= appraisalIndexList.get(i);
//            MainIndicatorsInfo info = infoMap.get(appraisalIndex.getId());
//            map.put("v" + (2 * (i +1)), null);
//            map.put("v" + (2 * (i +1) - 1), null);
//            if (info != null){
//                map.put("v" + (2 * (i +1)), info.getBudgetValue());
//                map.put("v" + (2 * (i +1) - 1), info.getLastCompleteValue());
//            }
//        }
//        return map;
//    }
//
//    private List<Map<String, Object>> listToMapList(List<MainIndicatorsInfo> mainIndicatorsInfoList, String fillingYear, List<String> appraisalIndexIds, boolean isReportOrg){
//        int year = Integer.valueOf(fillingYear);
//        Map<String, Object> budgetMap = new HashMap<>();
//        budgetMap.put(YEAR_KEY, fillingYear);
//        Map<String, Object> lastCompleteMap = new HashMap<>();
//        lastCompleteMap.put(YEAR_KEY, String.valueOf(year - 1));
//        Map<String, Object> beforeLastCompleteMap = new HashMap<>();
//        beforeLastCompleteMap.put(YEAR_KEY, String.valueOf(year - 2));
//        for (MainIndicatorsInfo mainIndicatorsInfo : mainIndicatorsInfoList){
//            if (isReportOrg && (mainIndicatorsInfo.getAppraisalIndexName().equals(JZCSYL_NAME)
//                    || mainIndicatorsInfo.getAppraisalIndexName().equals(GMJZCSYL_NAME))){
//                continue;
//            }
//            budgetMap.put(mainIndicatorsInfo.getAppraisalIndexName(),
//                    BigDecimalUtil.add(mainIndicatorsInfo.getBudgetValue(), (BigDecimal) budgetMap.get(mainIndicatorsInfo.getAppraisalIndexName())));
//            lastCompleteMap.put(mainIndicatorsInfo.getAppraisalIndexName(),
//                    BigDecimalUtil.add(mainIndicatorsInfo.getLastCompleteValue(), (BigDecimal) lastCompleteMap.get(mainIndicatorsInfo.getAppraisalIndexName())));
//            beforeLastCompleteMap.put(mainIndicatorsInfo.getAppraisalIndexName(),
//                    BigDecimalUtil.add(mainIndicatorsInfo.getBeforeLastCompleteValue(), (BigDecimal) beforeLastCompleteMap.get(mainIndicatorsInfo.getAppraisalIndexName())));
//        }
//        if (isReportOrg){
//            String reportOrgId = gzwProperties.getReportId();
//            setMapValue(JZCSYL, JZCSYL_NAME, fillingYear, lastCompleteMap, beforeLastCompleteMap, reportOrgId);
//            setMapValue(GMJZCSYL, GMJZCSYL_NAME, fillingYear, lastCompleteMap, beforeLastCompleteMap, reportOrgId);
//            //净资产收益率 预算值 合并节点计算
//            BigDecimal budgetJlr = (BigDecimal) budgetMap.get(JLR_NAME);
//            BigDecimal budgetJzc = (BigDecimal) budgetMap.get(QMJZC_NAME);
//            BigDecimal lastCompleteJzc = (BigDecimal) lastCompleteMap.get(QMJZC_NAME);
//            budgetMap.put(JZCSYL_NAME, BigDecimalUtil.divide(budgetJlr, BigDecimalUtil.add(budgetJzc, lastCompleteJzc), 2, BigDecimal.ROUND_HALF_UP, 200));
//        }
//        List<Map<String, Object>> list = Stream.of(beforeLastCompleteMap, lastCompleteMap, budgetMap).collect(Collectors.toList());
//        //根据选择指标过滤
//        if (isReportOrg && CollectionUtil.isNotEmpty(appraisalIndexIds)){
//            List<AppraisalIndex> appraisalIndexList = appraisalIndexService.list(Wrappers.<AppraisalIndex>lambdaQuery()
//                    .in(AppraisalIndex::getId, appraisalIndexIds));
//            List<String> budgetKeyList = lastCompleteMap.keySet().stream().collect(Collectors.toList());
//            List<String> indexNameList = appraisalIndexList.stream().map(AppraisalIndex::getName).collect(Collectors.toList());
//            for (String key : budgetKeyList){
//                if (!indexNameList.contains(key) && !"YEAR_KEY".equals(key)){
//                    budgetMap.remove(key);
//                    lastCompleteMap.remove(key);
//                    beforeLastCompleteMap.remove(key);
//                }
//            }
//        }
//        return list;
//    }
//
//    /**
//     * 从ComplexIndicatorsValue表中取数
//     * @param code
//     * @param codeName
//     * @param year
//     * @param lastCompleteMap
//     * @param beforeLastCompleteMap
//     * @param reportOrgId
//     */
//    private void setMapValue(String code, String codeName, String year, Map<String, Object> lastCompleteMap, Map<String, Object> beforeLastCompleteMap, String reportOrgId){
//        int intYear = Integer.valueOf(year);
//        ComplexIndicatorsValue beforeComplexIndicatorsValue = complexIndicatorsValueService.getOne(Wrappers.<ComplexIndicatorsValue>lambdaQuery()
//                .eq(ComplexIndicatorsValue::getIndicatorsCode, code)
//                .eq(ComplexIndicatorsValue::getOrgId,reportOrgId )
//                .eq(ComplexIndicatorsValue::getYear, intYear - 2)
//                .eq(ComplexIndicatorsValue::getMonth, 12));
//        BigDecimal beforeLastCompleteValue = beforeComplexIndicatorsValue != null ? beforeComplexIndicatorsValue.getValue() : new BigDecimal(0);
//        beforeLastCompleteMap.put(codeName, beforeLastCompleteValue);
//        ComplexIndicatorsValue complexIndicatorsValue = complexIndicatorsValueService.getOne(Wrappers.<ComplexIndicatorsValue>lambdaQuery()
//                .eq(ComplexIndicatorsValue::getIndicatorsCode, code)
//                .eq(ComplexIndicatorsValue::getOrgId, reportOrgId)
//                .eq(ComplexIndicatorsValue::getYear, intYear - 1)
//                .eq(ComplexIndicatorsValue::getMonth, 12));
//        BigDecimal lastCompleteValue = complexIndicatorsValue != null ? complexIndicatorsValue.getValue() : new BigDecimal(0);
//        lastCompleteMap.put(codeName, lastCompleteValue);
//    }
//
//    /**
//     * 原水map
//     * @param orgVOList
//     * @param orgIdValueMap
//     * @param appraisalIndexList
//     * @param ysMap
//     * @return
//     */
//    private List<Map<String, Object>> infoToMapTree(
//                                                    String year,
//                                                    List<OrgVO> orgVOList,
//                                                    Map<String, List<MainIndicatorsInfo>> orgIdValueMap,
//                                                    List<AppraisalIndex> appraisalIndexList,
//                                                    Map<String, Object> ysMap){
//        List<Map<String, Object>> childList = new ArrayList<>();
//        String countDate = year + "-12";
//        for (OrgVO orgVO : orgVOList){
//            List<MainIndicatorsInfo> infoList = new ArrayList<>();
//            Map<String, Object> map = new HashMap<>();
//            map.put(ORG_NAME_KEY, orgVO.getName());
//            if (orgVO.getName().equals(YUANSHUI_NAME)){
//                ysMap = map;
//            }
//            if (CollectionUtil.isNotEmpty(orgVO.getChildren())){
//                map.put(CHILDREN_KEY, infoToMapTree(year, orgVO.getChildren(), orgIdValueMap, appraisalIndexList, ysMap));
//            }
//            boolean unitFlag = IS_UNIT.equals(orgVO.getIsUnit()) && (!orgService.getDTFlag(countDate) || !orgService.isDT(orgVO.getId()));
//            if (unitFlag){
//                String summaryKey = orgVO.getId() + StringPool.DASH + SUMMARY_NAME;
//                String unitKey = orgVO.getId() + StringPool.DASH + orgVO.getName();
//                Map<String, Object> unitMap = new HashMap<>();
//                unitMap.put(ORG_NAME_KEY, orgVO.getName() + "(本部)");
//                if (orgIdValueMap.containsKey(unitKey)){
//                    List<MainIndicatorsInfo> unitInfoList = orgIdValueMap.get(unitKey);
//                    infoToMap(appraisalIndexList, unitInfoList, unitMap);
//                }
//                List<Map<String, Object>> children = (List<Map<String, Object>>)map.get(CHILDREN_KEY);
//                children.add(0, unitMap);
//                map.put(CHILDREN_KEY, children);
//                if (orgIdValueMap.containsKey(summaryKey)){
//                   infoList = orgIdValueMap.get(summaryKey);
//                }
//            }else {
//                infoList = orgIdValueMap.get(orgVO.getId());
//            }
//
//            infoToMap(appraisalIndexList, infoList, map);
//            childList.add(map);
//        }
//
//        if (gzwProperties.getReportId().equals(orgVOList.get(0).getId())){
//            Map<String, Object> map = childList.get(0);
//            List<Map<String, Object>> tempList = new ArrayList<>();
//            tempList.addAll((List<Map<String, Object>>)map.get(CHILDREN_KEY));
//            tempList.add(map);
//            String jlrKey = "";
//            String jzcKey = "";
//            String lastJzcKey = "";
//            String budgetJzcsylkey = "";
//            String jzcsylkey = "";
//            String budegtJzcsylGrowthKey = "";
//            for (AppraisalIndex appraisalIndex : appraisalIndexList){
//                // 净利润
//                if (JLR_NAME.equals(appraisalIndex.getName())){
//                    jlrKey = appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY;
//                }
//                //
//                if (QMJZC_NAME.equals(appraisalIndex.getName())){
//                    jzcKey = appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY;
//                    lastJzcKey = appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY;
//                }
//                if (JZCSYL_NAME.equals(appraisalIndex.getName())){
//                    jzcsylkey = appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY;
//                    budgetJzcsylkey = appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY;
//                    budegtJzcsylGrowthKey = appraisalIndex.getId() + StringPool.DASH + BUDGET_GROWTH_RATE_KEY;
//                    setValueByComplexIndicators(year, gzwProperties.getReportId(), map, JZCSYL, appraisalIndex.getId());
//                    continue;
//                }
//                if (GMJZCSYL_NAME.equals(appraisalIndex.getName())){
//                    setValueByComplexIndicators(year, gzwProperties.getReportId(), map, GMJZCSYL, appraisalIndex.getId());
//                    continue;
//                }
//                BigDecimal beforeLastCompleteValue = new BigDecimal(0);
//                BigDecimal lastCompleteValue = new BigDecimal(0);
//                BigDecimal budgetValue = new BigDecimal(0);
//                String beforeLastCompleteValueKey = appraisalIndex.getId() + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY;
//                String lastCompleteValueKey = appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY;
//                String budgetValueKey = appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY;
//                for (Map<String, Object> childMap : tempList){
//                    if (childMap.containsKey(beforeLastCompleteValueKey)){
//                        beforeLastCompleteValue = BigDecimalUtil.add(beforeLastCompleteValue, (BigDecimal) childMap.get(beforeLastCompleteValueKey));
//                    }
//                    if (childMap.containsKey(lastCompleteValueKey)){
//                        lastCompleteValue = BigDecimalUtil.add(lastCompleteValue, (BigDecimal) childMap.get(lastCompleteValueKey));
//                    }
//                    if (childMap.containsKey(budgetValueKey)){
//                        budgetValue = BigDecimalUtil.add(budgetValue, (BigDecimal) childMap.get(budgetValueKey));
//                    }
//                }
//                map.put(beforeLastCompleteValueKey, beforeLastCompleteValue);
//                map.put(lastCompleteValueKey, lastCompleteValue);
//                map.put(budgetValueKey, budgetValue);
//
//                BigDecimal lastGrowthRate = BigDecimalUtil.divide(BigDecimalUtil.subtract(lastCompleteValue,
//                        beforeLastCompleteValue), beforeLastCompleteValue, 2, BigDecimal.ROUND_HALF_UP, 100);
//                BigDecimal budgetGrowthRate = BigDecimalUtil.divide(BigDecimalUtil.subtract(budgetValue, lastCompleteValue), lastCompleteValue, 2, BigDecimal.ROUND_HALF_UP, 100);
//                if (lastGrowthRate != null){
//                   map.put(appraisalIndex.getId() + StringPool.DASH + LAST_GROWTH_RATE_KEY, BigDecimalUtil.toShortString(lastGrowthRate, 2) + "%");
//                }
//                if (budgetGrowthRate != null){
//                    map.put(appraisalIndex.getId() + StringPool.DASH + BUDGET_GROWTH_RATE_KEY, BigDecimalUtil.toShortString(budgetGrowthRate, 2) + "%");
//                }
//            }
//            //预算值 净资产收益率计算
//            if (map.containsKey(jlrKey) && map.containsKey(jzcKey) && map.containsKey(lastJzcKey)){
//                BigDecimal jlr = (BigDecimal) map.get(jlrKey);
//                BigDecimal jzc = (BigDecimal) map.get(jzcKey);
//                BigDecimal lastJzc = (BigDecimal) map.get(lastJzcKey);
//                BigDecimal budgetJzcsylRate = BigDecimalUtil.divide(jlr, BigDecimalUtil.add(jzc, lastJzc), 2, BigDecimal.ROUND_HALF_UP, 200);
//                map.put(budgetJzcsylkey, BigDecimalUtil.toShortString(budgetJzcsylRate, 2));
//                if (budgetJzcsylRate != null && map.containsKey(jzcsylkey)){
//                    map.put(budegtJzcsylGrowthKey, BigDecimalUtil.toShortString(BigDecimalUtil
//                            .divide(BigDecimalUtil.subtract(budgetJzcsylRate, (BigDecimal) map.get(jzcsylkey)), (BigDecimal) map.get(jzcsylkey), 2, BigDecimal.ROUND_HALF_UP, 100), 2) + "%");
//                }
//            }
//
//        }
//        return childList;
//
//    }
//
//    private void setValueByComplexIndicators(String year, String orgId, Map<String, Object> map, String code, Long appraisalIndexId){
//        String beforeLastCompleteValueKey = appraisalIndexId + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY;
//        String lastCompleteValueKey = appraisalIndexId + StringPool.DASH + LAST_COMPLETE_VALUE_KEY;
//        int intYear = Integer.valueOf(year);
//        ComplexIndicatorsValue beforeComplexIndicatorsValue = complexIndicatorsValueService.getOne(Wrappers.<ComplexIndicatorsValue>lambdaQuery()
//                .eq(ComplexIndicatorsValue::getIndicatorsCode, code)
//                .eq(ComplexIndicatorsValue::getOrgId, orgId)
//                .eq(ComplexIndicatorsValue::getYear, intYear - 2)
//                .eq(ComplexIndicatorsValue::getMonth, 12));
//        BigDecimal beforeLastCompleteValue = beforeComplexIndicatorsValue != null ? beforeComplexIndicatorsValue.getValue() : new BigDecimal(0);
//        map.put(beforeLastCompleteValueKey, beforeLastCompleteValue);
//        ComplexIndicatorsValue complexIndicatorsValue = complexIndicatorsValueService.getOne(Wrappers.<ComplexIndicatorsValue>lambdaQuery()
//                .eq(ComplexIndicatorsValue::getIndicatorsCode, code)
//                .eq(ComplexIndicatorsValue::getOrgId, orgId)
//                .eq(ComplexIndicatorsValue::getYear, intYear - 1)
//                .eq(ComplexIndicatorsValue::getMonth, 12));
//        BigDecimal lastCompleteValue = complexIndicatorsValue != null ? complexIndicatorsValue.getValue() : new BigDecimal(0);
//        map.put(lastCompleteValueKey, lastCompleteValue);
//        BigDecimal lastGrowthRate = BigDecimalUtil.divide(BigDecimalUtil.subtract(lastCompleteValue,
//                beforeLastCompleteValue), beforeLastCompleteValue, 2, BigDecimal.ROUND_HALF_UP, 100);
//        if (lastGrowthRate != null) {
//            map.put(appraisalIndexId + StringPool.DASH + LAST_GROWTH_RATE_KEY, BigDecimalUtil.toShortString(lastGrowthRate, 2) + "%");
//        }
//    }
//
//    private void infoToMap(List<AppraisalIndex> appraisalIndexList, List<MainIndicatorsInfo> infoList, Map<String, Object> map){
//        if (CollectionUtil.isEmpty(infoList) || CollectionUtil.isEmpty(appraisalIndexList)){
//            return;
//        }
//        Map<Long, MainIndicatorsInfo> infoMap = infoList.stream().collect(Collectors.toMap(MainIndicatorsInfo::getAppraisalIndexId, info -> info));
//        for (AppraisalIndex appraisalIndex : appraisalIndexList){
//            if (infoMap.containsKey(appraisalIndex.getId())){
//                MainIndicatorsInfo mainIndicatorsInfo = infoMap.get(appraisalIndex.getId());
//                BigDecimal lastGrowthRate = BigDecimalUtil.divide(BigDecimalUtil.subtract(mainIndicatorsInfo.getLastCompleteValue(),
//                        mainIndicatorsInfo.getBeforeLastCompleteValue()), mainIndicatorsInfo.getBeforeLastCompleteValue(), 2, BigDecimal.ROUND_HALF_UP, 100);
//                BigDecimal budgetGrowthRate = BigDecimalUtil.divide(BigDecimalUtil.subtract(mainIndicatorsInfo.getBudgetValue(),
//                        mainIndicatorsInfo.getLastCompleteValue()), mainIndicatorsInfo.getLastCompleteValue(), 2, BigDecimal.ROUND_HALF_UP, 100);
//                map.put(appraisalIndex.getId() + StringPool.DASH + BEFORE_LAST_COMPLETE_VALUE_KEY, mainIndicatorsInfo.getBeforeLastCompleteValue());
//                map.put(appraisalIndex.getId() + StringPool.DASH + LAST_COMPLETE_VALUE_KEY, mainIndicatorsInfo.getLastCompleteValue());
//                map.put(appraisalIndex.getId() + StringPool.DASH + BUDGET_VALUE_KEY, mainIndicatorsInfo.getBudgetValue());
//                if (lastGrowthRate != null){
//                    map.put(appraisalIndex.getId() + StringPool.DASH + LAST_GROWTH_RATE_KEY, BigDecimalUtil.toShortString(lastGrowthRate, 2) + "%");
//                }
//                if (budgetGrowthRate != null){
//                    map.put(appraisalIndex.getId() + StringPool.DASH + BUDGET_GROWTH_RATE_KEY, BigDecimalUtil.toShortString(budgetGrowthRate, 2) + "%");
//                }
//            }
//        }
//    }
//
//    @Override
//    @Transactional(rollbackFor=RuntimeException.class)
//    public boolean deleteLogic(List<Long> ids) {
//        for (Long id : ids) {
//            BaseMainIndicators baseMainIndicators = getById(id);
//            if (baseMainIndicators == null) {
//                return false;
//            } else if (baseMainIndicators.getStatus() != null &&
//                    (baseMainIndicators.getStatus() != FormStatusConstant.STASH && baseMainIndicators.getStatus() != FormStatusConstant.UNREVIEWED)) {
//                return false;
//            }
//            formWorkflowService.deleteProcessInstance(String.valueOf(id));
//        }
//
//        boolean result = super.deleteLogic(ids);
//        if (result){
//            businessIndicatorsInfoService.remove(Wrappers.<BusinessIndicatorsInfo>lambdaQuery()
//                    .in(BusinessIndicatorsInfo::getBaseId, ids));
//            mainIndicatorsInfoService.remove(Wrappers.<MainIndicatorsInfo>lambdaQuery()
//                    .in(MainIndicatorsInfo::getBaseId, ids));
//        }
//
//        return result;
//    }
//
//    /**
//     * 统一处理状态机事件方法
//     * @param id 主键
//     * @param updateStatus 更新状态
//     * @param comment
//     * @return boolean
//     */
//    private Boolean handleStatus(Long id, int updateStatus, String comment) {
//        try {
//            BaseMainIndicators baseMainIndicators = getById(id);
//            baseMainIndicators.setStatus(updateStatus);
//            updateById(baseMainIndicators);
//            return true;
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//            return false;
//        }
//    }
//
//    private List<BaseMainIndicatorsVO> orgVOToIndicatorsVO(String fillingYear, List<OrgVO> orgVOList, Map<String, BaseMainIndicatorsVO> orgIdMap){
//        List<BaseMainIndicatorsVO> childList = new ArrayList<>();
//        for (OrgVO orgVO : orgVOList){
//            BaseMainIndicatorsVO baseMainIndicatorsVO = orgIdMap.get(orgVO.getId());
//            if (baseMainIndicatorsVO == null){
//                baseMainIndicatorsVO = new BaseMainIndicatorsVO();
//                baseMainIndicatorsVO.setFillingUnitId(orgVO.getId());
//                baseMainIndicatorsVO.setStatus(FormStatusConstant.NOFILLING);
//                baseMainIndicatorsVO.setFillingYear(fillingYear);
//            }
//            baseMainIndicatorsVO.setFillingUnitName(orgVO.getName());
//            childList.add(baseMainIndicatorsVO);
//            if (CollectionUtil.isNotEmpty(orgVO.getChildren())){
//                baseMainIndicatorsVO.setChildren(orgVOToIndicatorsVO(fillingYear, orgVO.getChildren(), orgIdMap));
//            }
//        }
//        return childList;
//    }
//}
